How to use Grid search to find the optimal hyperparameters ?
47 次查看(过去 30 天)
显示 更早的评论
% Train the classifier
knn = ClassificationKNN.fit(Xtrain,Ytrain,'Distance','seuclidean');
0 个评论
回答(1 个)
Mohith Kulkarni
2020-12-9
编辑:Mohith Kulkarni
2020-12-11
Use the 'OptimizeHyperparameters' Name-Value pair argument to specify the Parameters to optimize when creating the 'ClassificationKNN' model using 'fitcknn'. Use the 'HyperparameterOptimizationOptions' to specify the Optimizer for the model. Refer the code below.
Mdl = fitcknn(X,Y,'OptimizeHyperparameters','auto',...
'HyperparameterOptimizationOptions',...
struct('Optimizer','gridsearch'))
You can use this model for fitting the data with the specified optimization options.
Refer the documention of fitcknn and ClassificationKNN for more information on the Name-Value pair arguments.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Statistics and Machine Learning Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!