how to use predict and forecast

3 views (last 30 days)
DARLINGTON ETAJE
DARLINGTON ETAJE on 21 Oct 2019
Commented: DARLINGTON ETAJE on 21 Oct 2019
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);
  2 Comments
DARLINGTON ETAJE
DARLINGTON ETAJE on 21 Oct 2019
Hello John,
Thanks for your comment. That is not the case here. There is a 95 percent accuracy when using the dataset as one..meaning using holdout to divide the data into training set and testing set. But when predicting the future, the story changes....I am positive it's a problem with the code...

Sign in to comment.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!