Filter löschen
Filter löschen

Posterior probability for cross-validated fitcecoc model

5 Ansichten (letzte 30 Tage)
Noam
Noam am 22 Jan. 2024
Kommentiert: Noam am 24 Jan. 2024
I'm trying to get posterior probabilities, rather than prediction scores from a cross-validated fitcecoc model using the following
t = templateSVM('Standardize',true);
Modelall = fitcecoc(X,Y,'Learners',t,'ClassNames', unique(stimNum),'Options',opts,'FitPosterior', true);
[label,~,~,Posterior] = resubPredict(Modelall);
However, when cross-validation is turned on
Modelall = fitcecoc(X,Y,'Learners',t,'ClassNames', unique(stimNum),'Options',opts,'FitPosterior', true, 'CrossVal','on','KFold' ,10);
I get the following error:
"Incorrect number or types of inputs or outputs for function 'resubPredict'."
is there any way to get the prediction probability of a multiclass cross-validated classifier analogous to a binary SVM (using 'fitSVMPosterior')?
Thanks in advance

Akzeptierte Antwort

Aditya
Aditya am 24 Jan. 2024
Hi Noam,
When you have a cross-validated error-correcting output codes (ECOC) model created with fitcecoc and the 'CrossVal','on' option, you cannot use resubPredict to get the predictions or posterior probabilities. Instead, you should use kfoldPredict to obtain the cross-validated predictions and posterior probabilities. Here's how you can do it:
% Cross-validated ECOC model
opts = statset('UseParallel', false); % Set 'UseParallel' to true if you want to use parallel computing
Modelall = fitcecoc(X, Y, 'Learners', t, 'ClassNames', unique(Y), ...
'Options', opts, 'FitPosterior', true, 'CrossVal', 'on', 'KFold', 10);
% Get the predicted labels and posterior probabilities for each fold
[label,~,~,Posterior] = kfoldPredict(Modelall);
The kfoldPredict function will return the cross-validated predicted labels in label and the posterior probabilities in Posterior. The syntax label,~,~,Posterioris used to ignore the second and third output arguments from kfoldPredict and only obtain the labels and posterior probabilities.
For additional examples and documentation, you can refer to the official MathWorks documentation page for fitcecoc” function, which includes an example of using kfoldPredict with a cross-validated ECOC model.
Hope this helps you to resolve the issue!

Weitere Antworten (0)

Kategorien

Mehr zu Statistics and Machine Learning Toolbox finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by