how to use predict and forecast
Ältere Kommentare anzeigen
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 Kommentare
John D'Errico
am 21 Okt. 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.
DARLINGTON ETAJE
am 21 Okt. 2019
Antworten (0)
Kategorien
Mehr zu Classification finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!