Borrar filtros
Borrar filtros

Error using fitecoc, validatestring in glmfit

1 visualización (últimos 30 días)
Madeline Boyce
Madeline Boyce el 22 de Feb. de 2022
Respondida: Aditya el 20 de Oct. de 2023
Hello,
I am trying to train an ECOC and use it to predict on future data. It seemed to be working, but I am now getting an error message that I cannot figure out. The code continues to run, it just pops up a bunch of error messages. The error message is very long and goes through a fairly tall calltree, but ends with this:
'Error using glmfit (line 141)↵Expected input to match one of these values:↵↵'identity', 'log', 'logit', 'probit', 'comploglog', 'reciprocal', 'logloglink'↵↵The input, 'link', did not match any of the valid values.'
I have not been able to find any answers, and I cannot figure out what I could have changed in my script to cause it. The calltree goes through all of Matlabs own code, which I have not changed at all. Here is the segment of code I am running (italicized lines generating the error):
t = templateSVM('Standardize',true,'KernelFunction','gaussian'); %create a blank SVM template
Mdl = fitcecoc(x,y,'Learners',t,'FitPosterior',true,... %Train the ECOC classifier using the SVM template
'ClassNames',{'Non-PD','arc','trk','cor'},'Verbose',2);
CVMdl = crossval(Mdl); %cross validate
genError = kfoldLoss(CVMdl) %generalized estimation error
[label,~,~,Posterior] = resubPredict(Mdl,'Verbose',1); %Predict the training-sample labels and class posterior probabilities.
Thank you!

Respuestas (1)

Aditya
Aditya el 20 de Oct. de 2023
Hi Madeline,
I understand that you are encountering an error while working with ‘fitcecoc’ function. I have tested out your code by using sample data, and it executed successfully without any errors. To further assist you, kindly provide the specific data that you are using.
For your reference, I have included the code that I have used for testing.
% Sample data
x = randn(100, 10); % Replace with your own input data
y = randi([1, 4], 100, 1); % Replace with your own class labels
% Convert numeric class labels to cell array of strings
classLabels = {'Non-PD', 'arc', 'trk', 'cor'};
y = classLabels(y);
% Create a blank SVM template
t = templateSVM('Standardize', true, 'KernelFunction', 'gaussian');
% Train the ECOC classifier using the SVM template
Mdl = fitcecoc(x, y, 'Learners', t, 'FitPosterior', true, ...
'ClassNames', {'Non-PD', 'arc', 'trk', 'cor'}, 'Verbose', 2);
% Cross-validate
CVMdl = crossval(Mdl);
genError = kfoldLoss(CVMdl); % Generalized estimation error
% Predict the training-sample labels and class posterior probabilities
[label, ~, ~, Posterior] = resubPredict(Mdl, 'Verbose', 1);
Hope this helps!

Community Treasure Hunt

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

Start Hunting!

Translated by