get prediction of all binary learners for multi-class classification
1 次查看(过去 30 天)
显示 更早的评论
When I use fitcecoc to perform multi-category classification, kfordpredict function only give me the Yhat after error correcting(pool results from all binary learners), how can I see raw results for all binary learners within the model?
0 个评论
采纳的回答
Aditya Patil
2021-2-16
You can get the underlying compact models using the Trained Property. You can call the predict function on these models.
You can also get the binary learners from the compact models, as shown in the Inspect Binary Learner Properties of ECOC Classifier example. You will have to reimplement the Error-Correcting Output Codes Model if you want to aggregate the results. If not, you can pass the input data to the binary classifiers, and get the required result.
Here is an basic code example
load fisheriris
X = meas(:,3:4);
Y = species;
CVMdl = fitcecoc(X,Y, 'CrossVal',"on");
cvsize = size(CVMdl.Trained, 1);
for i = 1:cvsize
trainedMdl = CVMdl.Trained{i};
blsize = size(trainedMdl.BinaryLearners, 1);
for j = 1:blsize
blmdl = trainedMdl.BinaryLearners{j};
yhat = predict(blmdl, X);
% postprocess the yhat as required
end
end
Note that crossvalidated models are intended to be used for validating the accuracy of the model, and not for prediction in general.
0 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!