'naivebayes' learner option fails when optimizing hyper-parameters for 'fitcecoc' function.

1 visualizzazione (ultimi 30 giorni)
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.

Risposta accettata

Don Mathis
Don Mathis il 10 Ago 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 Commenti
Andres G.
Andres G. il 11 Ago 2021
Thanks for this answer - this solves my problem. Perhaps the documentation for fitcecoc could be updated as it really does seem wrong (or at least confusing) as is. Anyway, thank you!
Alan Weiss
Alan Weiss il 11 Ago 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

Accedi per commentare.

Più risposte (0)

Prodotti


Release

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by