Why does fitcsvm support 'KFold' models only with fixed hyper-parameters?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I would like to train a KFold model with modified hyper-parameters.
The following works:
cvModel = fitcsvm(XTrain, yTrain, ...
'KernelFunction', kernelType, ...
'Weights', weights, ...
'KFold', nPartitions);
However, the following does not:
cvModel = fitcsvm(XTrain, yTrain, ...
'KernelFunction', kernelType, ...
'BoxConstraint', boxConstraint, ...
'KernelScale', kernelScale, ...
'PolynomialOrder', polynomialOrder, ...
'Weights', weights, ...
'KFold', nPartitions);
A model is trained, so the function completes without error, but it is not KFold. In the documentation , I noticed the following: To create a cross-validated model, you can use one of these four name-value pair arguments only: CVPartition, Holdout, KFold, or Leaveout.
So it is not allowed to use any other options than those named. How can I set BoxConstraint, KernelScale and other parameters and still yield a KFold model? It does not make sense to me at all why this should be prohibited!
Thanks for any support!
1 Kommentar
Don Mathis
am 11 Mai 2018
I can't replicate your results. When I run your second code, I get a partitioned model.
Running this:
XTrain = rand(100,3);
yTrain = categorical(rand(100,1)>.5);
kernelType = 'polynomial';
boxConstraint = 1;
kernelScale = 1;
polynomialOrder = 2;
weights = rand(100,1);
nPartitions = 3;
cvModel = fitcsvm(XTrain, yTrain, ...
'KernelFunction', kernelType, ...
'BoxConstraint', boxConstraint, ...
'KernelScale', kernelScale, ...
'PolynomialOrder', polynomialOrder, ...
'Weights', weights, ...
'KFold', nPartitions)
Outputs this:
cvModel =
classreg.learning.partition.ClassificationPartitionedModel
CrossValidatedModel: 'SVM'
PredictorNames: {'x1' 'x2' 'x3'}
ResponseName: 'Y'
NumObservations: 100
KFold: 3
Partition: [1×1 cvpartition]
ClassNames: [false true]
ScoreTransform: 'none'
Properties, Methods
Antworten (1)
Siehe auch
Kategorien
Mehr zu Classification finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!