'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!