get prediction of all binary learners for multi-class classification
조회 수: 2 (최근 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개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Classification Ensembles에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!