I am using machine learning classfier to predict my test accuracy. The classfier uses hold out to take data in random. How to I get the train accuracy using the code?
2 ビュー (過去 30 日間)
古いコメントを表示
%% -------------- Building Classifier ----------------------------
classification_model=fitcnb(data,'class_labels~PC1+PC2');
%% -------------- Test and Train sets ----------------------------
cv=cvpartition(classification_model.NumObservations,'HoldOut', 0.3);
cross_validated_model=crossval(classification_model,'cvpartition',cv);
%% -------------- Making Predictions for Test sets ---------------
predictions=predict(cross_validated_model.Trained{1},data(test(cv),1:end-1));
%% -------------- Analyzing the predictions ---------------------
results=confusionmat(cross_validated_model.Y(test(cv)),predictions)
0 件のコメント
回答 (1 件)
Omega
2024 年 12 月 5 日
Hi Atik,
To obtain the training accuracy, first, you need to extract the training data indices using the "training(cv)" MATLAB function and make predictions on it. Once you have the "trainPredictions," you can calculate the training accuracy by comparing it with the actual "trainLabels."
If you have further questions, please feel free to reach out to me by adding a comment.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Naive Bayes についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!