'naivebayes' learner option fails when optimizing hyper-parameters for 'fitcecoc' function.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Andres G.
am 9 Aug. 2021
Kommentiert: Alan Weiss
am 11 Aug. 2021
I am attempting to optimize a multi-class classifier. The classifier uses a (187 x 20) predictor matrix and a (187 x 1) categorical label vector (6 possible categories labeld 1 through 6). I am trying to run the optimization as follows:
Mdl = fitcecoc(predictorMat, labelVec, 'Learners', 'naivebayes', 'OptimizeHyperparameters','all',...
'HyperparameterOptimizationOptions',struct('AcquisitionFunctionName',...
'expected-improvement-plus', 'MaxObjectiveEvaluations', 10, 'UseParallel', ...
true, 'Kfold', 5));
This returns the following error:
Error using classreg.learning.paramoptim.BayesoptInfoCECOC/templateFromLearnersArg (line 127)
Optimizing hyperparameters for fitcecoc with learner type 'naivebayes' is not supported.
Error in classreg.learning.paramoptim.BayesoptInfoCECOC/getWeakLearnerTemplate (line 63)
Template = templateFromLearnersArg(this, LearnersArg);
Error in classreg.learning.paramoptim.BayesoptInfoCECOC (line 29)
this.WeakLearnerTemplate = getWeakLearnerTemplate(this, FitFunctionArgs);
Error in classreg.learning.paramoptim.BayesoptInfo.makeBayesoptInfo (line 127)
Obj = ConstructorFcn(Predictors, Response, FitFunctionArgs);
Error in classreg.learning.paramoptim.fitoptimizing (line 17)
BOInfo = classreg.learning.paramoptim.BayesoptInfo.makeBayesoptInfo(FitFunctionName, Predictors, Response, FitFunctionArgs);
Error in fitcecoc (line 283)
[obj, OptimResults] = classreg.learning.paramoptim.fitoptimizing('fitcecoc',X,Y,varargin{:});
This is odd since the expected hyper-parameter optimization behavior of 'fitceoc' with 'naivebayes' learners is described in the function's docs (see the Hyperparameter Optimization section about 3/4 of the way down that doc: https://www.mathworks.com/help/stats/fitcecoc.html). Moreover, in the code above changing the leaerner to 'svm' (or any of the other learner types such as 'knn' or 'kernel') goes through the optimization as expected. I am trying this on Matlab 2021a. Thanks for any help.
0 Kommentare
Akzeptierte Antwort
Don Mathis
am 10 Aug. 2021
It's true that Naive Bayes is not supported for optimization via fitcecoc. But since Naive Bayes is already a multiclass classifier, you can optimize it by itself:
Mdl = fitcnb(X,Y, 'OptimizeHyperparameters','all',...
'HyperparameterOptimizationOptions',struct('AcquisitionFunctionName',...
'expected-improvement-plus', 'MaxObjectiveEvaluations', 10, 'UseParallel', ...
true, 'Kfold', 5));
2 Kommentare
Alan Weiss
am 11 Aug. 2021
Indeed, we are now aware of the documentation problem and will fix it. Sorry for misleading you, and causing you to waste your time.
Alan Weiss
MATLAB mathematical toolbox documentation
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Classification Ensembles finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!