how to use predict and forecast
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
John D'Errico
il 21 Ott 2019
It does not mean there is a problem with the code. There could easily be a problem with the data, such that this particular set of data will never be able to predict some events correctly, no matter what model you use. It is not even that difficult to create such a dataset.
Risposte (0)
Vedere anche
Categorie
Scopri di più su Statistics and Machine Learning Toolbox in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!