trainAuto (cv.SVM) - MATLAB File Help |
Trains an SVM with optimal parameters
status = model.trainAuto(samples, responses)
status = model.trainAuto(csvFilename, [])
[...] = model.trainAuto(..., 'OptionName', optionValue, ...)
Data See the train method.
KFold Cross-validation parameter. The training set is
divided into KFold
subsets. One subset is used to test the
model, the others form the train set. So, the SVM algorithm is
executed KFold
times. default 10
Balanced If true and the problem is 2-class classification then the method creates more balanced cross-validation subsets that is proportions between classes in subsets are close to such proportion in the whole train dataset. default false
CGrid, GammaGrid, NuGrid, PGrid, CoeffGrid, DegreeGrid Iteration grid for the corresponding SVM parameter. A structure that represents the logarithmic grid range of SVM parameters. It is used for optimizing model accuracy by varying model parameters, the accuracy estimate being computed by cross-validation. It accepts a struct having the fields below. It also accepts a 3-element vector in which each parameter is specified in the same order as the supported struct:
The grid determines the following iteration sequence of the
model parameter values: minVal * logStep.^(0:n)
, where n
is the maximal index satisfying minVal*logStep^n < maxVal
.
The grid is logarithmic, so logStep
must always be greater
than 1. Defaults are:
struct('minVal',0.1, 'maxVal',500, 'logStep',5 )
struct('minVal',1e-5, 'maxVal',0.6, 'logStep',15)
struct('minVal',0.01, 'maxVal',100, 'logStep',7 )
struct('minVal',0.01, 'maxVal',0.2, 'logStep',3 )
struct('minVal',0.1, 'maxVal',300, 'logStep',14)
struct('minVal',0.01, 'maxVal',4, 'logStep',7 )
The method trains the SVM model automatically by choosing the
optimal parameters C
, Gamma
, P
, Nu
, Coef0
, Degree
of
an SVM model. Parameters are considered optimal when the
cross-validation estimate of the test set error is minimal.
If there is no need to optimize a parameter, the corresponding
grid step should be set to any value less than or equal to 1.
For example, to avoid optimization in gamma, set logStep = 0
in GammaGrid
, and minVal
, maxVal
as arbitrary numbers. In
this case, the value of the parameter Gamma
is taken for
gamma.
And, finally, if the optimization in a parameter is required but
the corresponding grid is unknown, you may set it by name to
obtain the default grid of that parameter. To generate a grid,
for example, for gamma, set GammaGrid='Gamma'
.
This function works for the classification (C_SVC
or NU_SVC
)
as well as for the regression (EPS_SVR
or NU_SVR
). For
ONE_CLASS
, no optimization is made and the usual SVM with the
specified parameters is executed.
Access | public |
Sealed | false |
Static | false |