Why does fitcsvm support 'KFold' models only with fixed hyper-parameters?

1 visualización (últimos 30 días)
normanius
normanius el 8 de Mayo de 2018
Comentada: Don Mathis el 11 de Mayo de 2018
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 comentario
Don Mathis
Don Mathis el 11 de Mayo de 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

Iniciar sesión para comentar.

Respuestas (1)

normanius
normanius el 8 de Mayo de 2018
A very related question: is the following equivalent?
cvModel1 = fitcsvm(XTrain, yTrain, ...
'KernelFunction', kernelType, ...
'Weights', weights, ...
'KFold', nPartitions);
cvModel2 = fitcsvm(XTrain, yTrain, ...
'KernelFunction', kernelType, ...
'Weights', weights);
cvModel2 = crossval(cvModel2, 'KFold', nPartitions);
In case cvModel1 and cvModel2 were equivalent, this would be the answer to my question.

Categorías

Más información sobre Classification en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by