how to use predict and forecast
3 views (last 30 days)
Show older comments
Hello Family,
I am trying to predict the class of future dataset: Unfortunately my code is completely misclassifying one class meaning there is a problem with the code.
This is the dataset:
https://drive.google.com/file/d/1tQdZ5XXQAECN6eahzhkt5xLpZA9eOyFk/view?usp=sharing
Here is the code I am currently using:
%D be the dataset
Data=D(1:500,1:end-1);
Data2=D(501:1000,1:end-1);
class_labels=D(1:500,6);
Data2labels=D(501:1000,6);
classification_model = fitcensemble(Data,'class_labels~var1+var2+var3+var4+var5')
cv = cvpartition(classification_model.NumObservations, 'HoldOut', 0.2);
cross_validated_model = crossval(classification_model,'cvpartition',cv);
Predictions_1 = predict(cross_validated_model.Trained{1},Data(test(cv),1:end-1));
Predictions_5 = predict(cross_validated_model{1}.Trained,Data2);
training_data = Data(training(cv),:);
labels = unique(class_labels);
Y = ismember(training_data.class_labels,labels{1});
Results_1 = confusionmat(cross_validated_model.Y(test(cv)),Predictions_1);
Results_5 = confusionmat(Data2labels,Predictions_5);
Answers (0)
See Also
Categories
Find more on Naive Bayes in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!