svcfit

C-Support Vector Classification.

Syntax

parameters = svcfit(X,y)

parameters = svcfit(X,y,options)

Inputs

X
Training data.
Type: double
Dimension: vector | matrix
y
Target values.
Type: double
Dimension: vector | matrix
options
Type: struct
C
Penalty parameter C of the error term (default: 1).
Type: double
Dimension: scalar
kernel
Kernel type to be used in the algorithm. Allowed values are 'linear', 'poly', 'rbf' (default), 'sigmoid'.
Type: char
Dimension: string
degree
Degree of the polynomial kernel function ('poly'). This parameter is ignored by other kernels. Default: 3
Type: integer
Dimension: scalar
gamma
Kernel coefficient for 'rbf', 'poly' and 'sigmoid' kernel. Allowed values are any float. If gamma is not assigned, then 1 / (n_features * variance(X)) is taken as gamma.
Type: double
Dimension: scalar
coef0
Independent term in kernel function (default: 0). It is only significant in 'poly' and 'sigmoid'.
Type: double | integer
Dimension: scalar
shrinking
Whether to use the shrinking heuristic.
Type: Boolean
Dimension: double | integer
tol
Tolerance of stopping criterion (default: 1e-3).
Type: double
Dimension: scalar
cache_size
Specify the size of kernel cache (in MB).
Type: double
Dimension: scalar
max_iter
Hard limit on iterations within solver (default: -1).
Type: integer
Dimension: scalar

Outputs

parameters
Contains all the values passed to svcfit method as options. Additionally it has below key-value pairs.
Type: struct
scorer
Function handle pointing to 'accuracy' function.
Type: function handle
support
Indices of support vectors.
Type: integer
Dimension: vector
support_vectors
Support vectors.
Type: double
Dimension: matrix
dual_coef
Coefficients of the support vector in the decision function.
Type: integer
Dimension: matrix
intercept
Constants in decision function.
Type: double
Dimension: matrix
coef
Weights assigned to features (coefficients in primal problem). This is available only if kernel is set to 'linear'. It is derived from dual_coef and support_vectors.
Type: double
Dimension: vector
n_samples
Number of rows in the training data.
Type: integer
Dimension: scalar
n_features
Number of columns in the training data.
Type: integer
Dimension: scalar

Example

Usage of svcfit

data = dlmread('digits.csv', ',');
X = data(:, 1:end-1);
y = data(:, end);

parameters = svcfit(X, y)
parameters = struct [
  C: 1
  coef: [Matrix] 45 x 64
  ...

Comments

The implementation is based on libsvm. The fit time complexity is more than quadratic with number of samples. This makes it hard to scale to dataset with more than a couple of 10000 samples. Multiclass support is handled by one-vs-one scheme. Output 'parameters' should be passed as input to svcpredict function