how to find minimum value of output corresponds to which input values in a loop/nested loop ? Error i am getting is Index exceeds the number of array elements.
Afficher commentaires plus anciens
i want to find for what value of c and what value of hh , the genError is minimum. The error i am getting is Index exceeds the number of array elements. Index must not exceed 1.
load fisheriris
X = meas;
Y = species;
TTT=0;
for c=[0.05 0.1]
for hh=[0.1 1]
TTT=TTT+1;
t = templateSVM('Standardize',true,'KernelFunction','gaussian','kernelscale',c,'boxconstraint',hh);
Mdl = fitcecoc(X,Y,'Learners',t,'FitPosterior',true,...
'ClassNames',{'setosa','versicolor','virginica'},...
'Verbose',2);
CVMdl = crossval(Mdl);
genError(TTT) = kfoldLoss(CVMdl);
end
end
[mingenaratederror min_index] = min(genError);
c_kscale = c(min_index); % get the corresponding value from the c array
hh_boxcon = hh(min_index); % get the corresponding value from the hh array
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!