Print parameters of classification model

5 Ansichten (letzte 30 Tage)
Louis
Louis am 27 Mär. 2020
Bearbeitet: Louis am 27 Mär. 2020
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!

Antworten (0)

Produkte


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by