Why does fitcsvm support 'KFold' models only with fixed hyper-parameters?
    4 views (last 30 days)
  
       Show older comments
    
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 Comment
  Don Mathis
    
 on 11 May 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
Answers (1)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
