I am using a linear svm an i would like to tune the boxconstraint parameter.

2 views (last 30 days)
I am using a linear svm and i would like to tune the boxconstraint parameter. I have tried different values but there are no results. my svm looks like:
svmtrain(trainingFeatures, trainingLabels,'Kernel_Function','linear',... 'boxconstraint',C,'tolkkt',(1e-3),'kktviolationlevel', 0);
trainingFeatures=[TrainingDataPositive;TrainingDataNegative];
size(TrainingDataNegative)=21354x1297 size(TrainingDataPositive)=8380x1297
How can i tune boxconstraint parameter( C parameter)in order to see different ErroRates (from function classperf) and pick the minimum.
Thanks

Accepted Answer

Cindy Solomon
Cindy Solomon on 6 May 2015
Edited: Cindy Solomon on 6 May 2015
Hi Konstantinos,
The adjustments you would make would highly depend on your specific data, but to clarify how the BoxConstraint impacts your SVM, this parameter lets you specify the soft margin in the SVM classifier you train. This in turn lets you control the trade-off between margin width and misclassification by specifying a single (scalar) value that specifies the soft margin for all vectors. To specify a hard margin, you can set this value to a very large number. Theoretically it could be set to infinity (inf in MATLAB), but this may cause numerical stability issues in the optimization algorithm and increases the training time (although it will also decrease the number of support vectors). In addition, I would recommend using "fitcsvm" instead of "svmtrain", as svmtrain will be removed in a future release of MATLAB.
Hope this helps!

More Answers (0)

Categories

Find more on Statistics and Machine Learning Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!