'naivebayes' learner option fails when optimizing hyper-parameters for 'fitcecoc' function.
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Don Mathis
2021-8-10
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 个评论
Alan Weiss
2021-8-11
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
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Classification Ensembles 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!