train (cv.SVM) - MATLAB File Help
cv.SVM/train

Trains the statistical model

status = model.train(samples, responses)
status = model.train(csvFilename, [])
[...] = model.train(..., 'OptionName', optionValue, ...)

Input

Output

Options

Options for Data (first variant with samples and reponses)

Options for Data (second variant for loading CSV file)

The method trains the SVM model. It follows the conventions of the generic train approach with the following limitations:

SVM models may be trained on a selected feature subset, and/or on a selected sample subset of the training set. To make it easier for you, the data options include the VarIdx and SampleIdx parameters. The former parameter identifies variables (features) of interest, and the latter one identifies samples of interest. Both vectors are either integer vectors (lists of 0-based indices) or logical masks of active variables/samples. You may pass empty input instead of either of the arguments, meaning that all of the variables/samples are used for training.

Example

For example, an Nx4 samples matrix of row layout with four numerical variables and one categorical response variable Nx1 can be specified as:

model.train(samples, responses, 'Flags',0, ...
    'Data',{'Layout','Row', 'VarType','NNNNC'});

Example

You can also directly load a dataset from a CSV file:

model.train('C:\path\to\data.csv', [], 'Flags',0, ...
    'Data',{'HeaderLineCount',1, 'Delimiter',','});
See also
Method Details
Access public
Sealed false
Static false