Print parameters of classification model
2 次查看(过去 30 天)
显示 更早的评论
I have trained classification models for which I am writing a result-display function to print information about the trained models
Specifically, I would like to use the for loop to print every parameter name and value pairs
I would like to avoid hardcoding parameter name to do this as I will be displaying results of many different types of classifiers
Below is the simple test script to train a decision tree:
% load dataset
load ionosphere
% train model - decision tree
model = fitctree(X, Y, 'SplitCriterion', 'gdi', 'MaxNumSplits', 100, ...
'KFold', 5);
I know that model.PadelParameters.LearnerTemplates{1} contains the FitTemplate property with parameter names and corresponding values. Below outputs show the parameters for the model trained above:
>> model.ModelParameters.LearnerTemplates{1,1}
ans =
Fit template for classification Tree.
SplitCriterion: 'gdi'
MinParent: []
MinLeaf: []
MaxSplits: 100
NVarToSample: []
MergeLeaves: []
Prune: []
PruneCriterion: []
QEToler: []
NSurrogate: []
MaxCat: []
AlgCat: []
PredictorSelection: []
UseChisqTest: []
Stream: []
Reproducible: []
Version: 2
Method: 'Tree'
Type: 'classification'
I would like to create a loop using fprintf to print parameter names and corresponding values for the ones with values without hardcoding the fieldnames. I have tried fieldnames method to see if I could extract field names but it returns empty cell...
Desired output looks like the following for the above test example:
|=======================================================================|
| Learner | Hyperparameter: Value |
|=======================================================================|
| classification Tree | SplitCriterion: 'gdi' |
| | MaxSplits: 100 |
| | Version: 2 |
Is there a method I can use to accomplish this task?
Any help will be greated appreciated!
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Classification Learner App 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!