Hyper-parameter optimization
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Elena Casiraghi
il 21 Set 2019
Risposto: Elena Casiraghi
il 24 Set 2019
1) When training an ECOC classifier for multiclass classification, with knn as base learner, how can I change the minimized function (from the classification error to a loss function I want to define)?
I'm now using this code (where the loss function is in the last line of code). If Preds are the predicted classes, labels are the true classes, N is the numebr of sample, my loss is:
myLoss = double(sum(abs(resPreds - labels)))/double(N); % this is the loss function I wish to minimize
% variable labels contains the labels of training data
tknn = templateKNN('Distance', @distKNN); % I WOULD LIKE TO USE THIS DISTANCE
N = size(XKnn,1);
c = cvpartition(N,'LeaveOut');
% Use leave one out
mdlknnCecoc = fitcecoc(XKnn,labelsRed, ...
'OptimizeHyperparameters','auto', ...
'HyperparameterOptimizationOptions',struct( 'UseParallel',...
true,'CVPartition',c), 'Learners',tknn);
resPreds = predict(mdlknnCecoc, XKnn); % I don't know why kfoldPredict function does not work
myLoss = double(sum(abs(resPreds - labels)))/double(N); % this is the loss function I wish to minimize
2 Commenti
Don Mathis
il 23 Set 2019
Is it important for you to use ECOC for this? fitcknn directly supports multiclass problems.
Risposta accettata
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Discriminant Analysis in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!