ClassificationKernel
statistics: ClassificationKernel
Gaussian kernel binary classifier for large data.
A ClassificationKernel object maps the predictors into a
randomized feature space whose inner product approximates a Gaussian
kernel, and then fits a linear model there. A kernel classifier is
therefore as nonlinear as a support vector machine with a Gaussian kernel,
while costing what a linear fit costs: nothing of size is ever
formed.
The expansion is the random Fourier basis of Rahimi and Recht, drawn once
when the model is fitted and kept with it, so predict maps new data
through the same basis. MATLAB approximates the same kernel by the
Fastfood construction, which reaches the same distribution more cheaply;
the two are interchangeable in distribution but not draw by draw, and the
draws come from different generators in any case, so the scores of a model
fitted here and one fitted in MATLAB differ even from the same seed.
What does not differ is what they estimate.
Like ClassificationLinear the object holds no copy of the training
data. It does hold the basis and the coefficients, so it is bounded by
the number of expansion dimensions rather than by the number of
observations.
Create a ClassificationKernel object with fitckernel.
See also: fitckernel, ClassificationLinear, ClassificationSVM
Source Code: ClassificationKernel
The ClassificationKernel class contains the following properties:
A positive scalar. It is the reciprocal of the product of
Lambda and the number of observations, so setting either of
the two in the constructor fixes the other, and giving both is an
error. This property is read-only.
Separate the two overlapping iris species through a randomized Gaussian kernel, and read the model the fit produced.
load fisheriris X = meas(51:end,:); Y = species(51:end); Mdl = ClassificationKernel (X, Y)
Mdl =
ClassificationKernel
ResponseName: 'Y'
ClassNames: {'versicolor' 'virginica'}
Learner: 'svm'
NumExpansionDimensions: 128
KernelScale: 1
Lambda: 0.01
BoxConstraint: 1
predict (Mdl, X([1, 51],:))
ans =
2x1 cell array
{'versicolor'}
{'virginica' }
The box constraint and the regularization strength are two names for the same quantity: setting either fixes the other.
load fisheriris X = meas(51:end,:); Y = species(51:end); Mdl = ClassificationKernel (X, Y, 'BoxConstraint', 4); Mdl.BoxConstraint
ans = 4
Mdl.Lambda
ans = 2.5000e-03
A column of the same type as the response supplied to the constructor. The second of the two is the positive class, the one a positive score belongs to. This property is read-only.
Separate the two overlapping iris species through a randomized Gaussian kernel, and read the model the fit produced.
load fisheriris X = meas(51:end,:); Y = species(51:end); Mdl = ClassificationKernel (X, Y)
Mdl =
ClassificationKernel
ResponseName: 'Y'
ClassNames: {'versicolor' 'virginica'}
Learner: 'svm'
NumExpansionDimensions: 128
KernelScale: 1
Lambda: 0.01
BoxConstraint: 1
predict (Mdl, X([1, 51],:))
ans =
2x1 cell array
{'versicolor'}
{'virginica' }
The box constraint and the regularization strength are two names for the same quantity: setting either fixes the other.
load fisheriris X = meas(51:end,:); Y = species(51:end); Mdl = ClassificationKernel (X, Y, 'BoxConstraint', 4); Mdl.BoxConstraint
ans = 4
Mdl.Lambda
ans = 2.5000e-03
A numeric row vector with one element per class, in the order of
ClassNames and summing to one. It defaults to the class
frequencies of the training data. This property is read-only.
Separate the two overlapping iris species through a randomized Gaussian kernel, and read the model the fit produced.
load fisheriris X = meas(51:end,:); Y = species(51:end); Mdl = ClassificationKernel (X, Y)
Mdl =
ClassificationKernel
ResponseName: 'Y'
ClassNames: {'versicolor' 'virginica'}
Learner: 'svm'
NumExpansionDimensions: 128
KernelScale: 1
Lambda: 0.01
BoxConstraint: 1
predict (Mdl, X([1, 51],:))
ans =
2x1 cell array
{'versicolor'}
{'virginica' }
The box constraint and the regularization strength are two names for the same quantity: setting either fixes the other.
load fisheriris X = meas(51:end,:); Y = species(51:end); Mdl = ClassificationKernel (X, Y, 'BoxConstraint', 4); Mdl.BoxConstraint
ans = 4
Mdl.Lambda
ans = 2.5000e-03
A square numeric matrix with one row and one column per class, whose element is the cost of classifying an observation of class into class . It defaults to one everywhere except the diagonal, which is zero. This property is read-only, as it is in MATLAB; a cost matrix is given to the constructor instead.
The costs are folded into the prior before the observations are
weighted, so a class that is costlier to misclassify weighs more in
the fit. They are read again by the 'mincost' and
'classifcost' losses.
Separate the two overlapping iris species through a randomized Gaussian kernel, and read the model the fit produced.
load fisheriris X = meas(51:end,:); Y = species(51:end); Mdl = ClassificationKernel (X, Y)
Mdl =
ClassificationKernel
ResponseName: 'Y'
ClassNames: {'versicolor' 'virginica'}
Learner: 'svm'
NumExpansionDimensions: 128
KernelScale: 1
Lambda: 0.01
BoxConstraint: 1
predict (Mdl, X([1, 51],:))
ans =
2x1 cell array
{'versicolor'}
{'virginica' }
The box constraint and the regularization strength are two names for the same quantity: setting either fixes the other.
load fisheriris X = meas(51:end,:); Y = species(51:end); Mdl = ClassificationKernel (X, Y, 'BoxConstraint', 4); Mdl.BoxConstraint
ans = 4
Mdl.Lambda
ans = 2.5000e-03
A character vector naming a transformation, or the text of the
function handle that was supplied. Assigning to it accepts either.
It defaults to 'logit' for a logistic learner and to
'none' for a support vector machine.
Separate the two overlapping iris species through a randomized Gaussian kernel, and read the model the fit produced.
load fisheriris X = meas(51:end,:); Y = species(51:end); Mdl = ClassificationKernel (X, Y)
Mdl =
ClassificationKernel
ResponseName: 'Y'
ClassNames: {'versicolor' 'virginica'}
Learner: 'svm'
NumExpansionDimensions: 128
KernelScale: 1
Lambda: 0.01
BoxConstraint: 1
predict (Mdl, X([1, 51],:))
ans =
2x1 cell array
{'versicolor'}
{'virginica' }
The box constraint and the regularization strength are two names for the same quantity: setting either fixes the other.
load fisheriris X = meas(51:end,:); Y = species(51:end); Mdl = ClassificationKernel (X, Y, 'BoxConstraint', 4); Mdl.BoxConstraint
ans = 4
Mdl.Lambda
ans = 2.5000e-03
A cell array of character vectors with one name per column of the
training data, defaulting to 'x1', 'x2' and so on.
This property is read-only.
Separate the two overlapping iris species through a randomized Gaussian kernel, and read the model the fit produced.
load fisheriris X = meas(51:end,:); Y = species(51:end); Mdl = ClassificationKernel (X, Y)
Mdl =
ClassificationKernel
ResponseName: 'Y'
ClassNames: {'versicolor' 'virginica'}
Learner: 'svm'
NumExpansionDimensions: 128
KernelScale: 1
Lambda: 0.01
BoxConstraint: 1
predict (Mdl, X([1, 51],:))
ans =
2x1 cell array
{'versicolor'}
{'virginica' }
The box constraint and the regularization strength are two names for the same quantity: setting either fixes the other.
load fisheriris X = meas(51:end,:); Y = species(51:end); Mdl = ClassificationKernel (X, Y, 'BoxConstraint', 4); Mdl.BoxConstraint
ans = 4
Mdl.Lambda
ans = 2.5000e-03
A row vector of column indices, empty when every predictor is numeric. This property is read-only.
Separate the two overlapping iris species through a randomized Gaussian kernel, and read the model the fit produced.
load fisheriris X = meas(51:end,:); Y = species(51:end); Mdl = ClassificationKernel (X, Y)
Mdl =
ClassificationKernel
ResponseName: 'Y'
ClassNames: {'versicolor' 'virginica'}
Learner: 'svm'
NumExpansionDimensions: 128
KernelScale: 1
Lambda: 0.01
BoxConstraint: 1
predict (Mdl, X([1, 51],:))
ans =
2x1 cell array
{'versicolor'}
{'virginica' }
The box constraint and the regularization strength are two names for the same quantity: setting either fixes the other.
load fisheriris X = meas(51:end,:); Y = species(51:end); Mdl = ClassificationKernel (X, Y, 'BoxConstraint', 4); Mdl.BoxConstraint
ans = 4
Mdl.Lambda
ans = 2.5000e-03
A character vector, defaulting to 'Y'. This property is
read-only.
Separate the two overlapping iris species through a randomized Gaussian kernel, and read the model the fit produced.
load fisheriris X = meas(51:end,:); Y = species(51:end); Mdl = ClassificationKernel (X, Y)
Mdl =
ClassificationKernel
ResponseName: 'Y'
ClassNames: {'versicolor' 'virginica'}
Learner: 'svm'
NumExpansionDimensions: 128
KernelScale: 1
Lambda: 0.01
BoxConstraint: 1
predict (Mdl, X([1, 51],:))
ans =
2x1 cell array
{'versicolor'}
{'virginica' }
The box constraint and the regularization strength are two names for the same quantity: setting either fixes the other.
load fisheriris X = meas(51:end,:); Y = species(51:end); Mdl = ClassificationKernel (X, Y, 'BoxConstraint', 4); Mdl.BoxConstraint
ans = 4
Mdl.Lambda
ans = 2.5000e-03
A cell array of character vectors. These name the original predictors, not the expansion dimensions, which have no names. This property is read-only.
Separate the two overlapping iris species through a randomized Gaussian kernel, and read the model the fit produced.
load fisheriris X = meas(51:end,:); Y = species(51:end); Mdl = ClassificationKernel (X, Y)
Mdl =
ClassificationKernel
ResponseName: 'Y'
ClassNames: {'versicolor' 'virginica'}
Learner: 'svm'
NumExpansionDimensions: 128
KernelScale: 1
Lambda: 0.01
BoxConstraint: 1
predict (Mdl, X([1, 51],:))
ans =
2x1 cell array
{'versicolor'}
{'virginica' }
The box constraint and the regularization strength are two names for the same quantity: setting either fixes the other.
load fisheriris X = meas(51:end,:); Y = species(51:end); Mdl = ClassificationKernel (X, Y, 'BoxConstraint', 4); Mdl.BoxConstraint
ans = 4
Mdl.Lambda
ans = 2.5000e-03
A positive integer scalar. It defaults to
2 .^ ceil (min (log2 (p) + 5, 15)) for p
predictors, so four predictors give 128 dimensions. More dimensions
approximate the kernel more closely and cost proportionally more.
This property is read-only.
Separate the two overlapping iris species through a randomized Gaussian kernel, and read the model the fit produced.
load fisheriris X = meas(51:end,:); Y = species(51:end); Mdl = ClassificationKernel (X, Y)
Mdl =
ClassificationKernel
ResponseName: 'Y'
ClassNames: {'versicolor' 'virginica'}
Learner: 'svm'
NumExpansionDimensions: 128
KernelScale: 1
Lambda: 0.01
BoxConstraint: 1
predict (Mdl, X([1, 51],:))
ans =
2x1 cell array
{'versicolor'}
{'virginica' }
The box constraint and the regularization strength are two names for the same quantity: setting either fixes the other.
load fisheriris X = meas(51:end,:); Y = species(51:end); Mdl = ClassificationKernel (X, Y, 'BoxConstraint', 4); Mdl.BoxConstraint
ans = 4
Mdl.Lambda
ans = 2.5000e-03
'hinge' for a support vector machine and 'logit' for a
logistic regression. This property is read-only.
Separate the two overlapping iris species through a randomized Gaussian kernel, and read the model the fit produced.
load fisheriris X = meas(51:end,:); Y = species(51:end); Mdl = ClassificationKernel (X, Y)
Mdl =
ClassificationKernel
ResponseName: 'Y'
ClassNames: {'versicolor' 'virginica'}
Learner: 'svm'
NumExpansionDimensions: 128
KernelScale: 1
Lambda: 0.01
BoxConstraint: 1
predict (Mdl, X([1, 51],:))
ans =
2x1 cell array
{'versicolor'}
{'virginica' }
The box constraint and the regularization strength are two names for the same quantity: setting either fixes the other.
load fisheriris X = meas(51:end,:); Y = species(51:end); Mdl = ClassificationKernel (X, Y, 'BoxConstraint', 4); Mdl.BoxConstraint
ans = 4
Mdl.Lambda
ans = 2.5000e-03
A nonnegative scalar, the reciprocal of the product of
BoxConstraint and the number of observations. This property
is read-only.
Separate the two overlapping iris species through a randomized Gaussian kernel, and read the model the fit produced.
load fisheriris X = meas(51:end,:); Y = species(51:end); Mdl = ClassificationKernel (X, Y)
Mdl =
ClassificationKernel
ResponseName: 'Y'
ClassNames: {'versicolor' 'virginica'}
Learner: 'svm'
NumExpansionDimensions: 128
KernelScale: 1
Lambda: 0.01
BoxConstraint: 1
predict (Mdl, X([1, 51],:))
ans =
2x1 cell array
{'versicolor'}
{'virginica' }
The box constraint and the regularization strength are two names for the same quantity: setting either fixes the other.
load fisheriris X = meas(51:end,:); Y = species(51:end); Mdl = ClassificationKernel (X, Y, 'BoxConstraint', 4); Mdl.BoxConstraint
ans = 4
Mdl.Lambda
ans = 2.5000e-03
A structure holding every parameter of the fit, with the
'auto' values as they were given rather than as they were
resolved. This property is read-only.
Separate the two overlapping iris species through a randomized Gaussian kernel, and read the model the fit produced.
load fisheriris X = meas(51:end,:); Y = species(51:end); Mdl = ClassificationKernel (X, Y)
Mdl =
ClassificationKernel
ResponseName: 'Y'
ClassNames: {'versicolor' 'virginica'}
Learner: 'svm'
NumExpansionDimensions: 128
KernelScale: 1
Lambda: 0.01
BoxConstraint: 1
predict (Mdl, X([1, 51],:))
ans =
2x1 cell array
{'versicolor'}
{'virginica' }
The box constraint and the regularization strength are two names for the same quantity: setting either fixes the other.
load fisheriris X = meas(51:end,:); Y = species(51:end); Mdl = ClassificationKernel (X, Y, 'BoxConstraint', 4); Mdl.BoxConstraint
ans = 4
Mdl.Lambda
ans = 2.5000e-03
Always 'ridge (L2)': a kernel model fits in the expanded
space, where a lasso penalty has nothing to select. This property is
read-only.
Separate the two overlapping iris species through a randomized Gaussian kernel, and read the model the fit produced.
load fisheriris X = meas(51:end,:); Y = species(51:end); Mdl = ClassificationKernel (X, Y)
Mdl =
ClassificationKernel
ResponseName: 'Y'
ClassNames: {'versicolor' 'virginica'}
Learner: 'svm'
NumExpansionDimensions: 128
KernelScale: 1
Lambda: 0.01
BoxConstraint: 1
predict (Mdl, X([1, 51],:))
ans =
2x1 cell array
{'versicolor'}
{'virginica' }
The box constraint and the regularization strength are two names for the same quantity: setting either fixes the other.
load fisheriris X = meas(51:end,:); Y = species(51:end); Mdl = ClassificationKernel (X, Y, 'BoxConstraint', 4); Mdl.BoxConstraint
ans = 4
Mdl.Lambda
ans = 2.5000e-03
A positive scalar dividing every predictor before the expansion, so a larger scale makes the kernel wider and the classifier smoother. This property is read-only.
Separate the two overlapping iris species through a randomized Gaussian kernel, and read the model the fit produced.
load fisheriris X = meas(51:end,:); Y = species(51:end); Mdl = ClassificationKernel (X, Y)
Mdl =
ClassificationKernel
ResponseName: 'Y'
ClassNames: {'versicolor' 'virginica'}
Learner: 'svm'
NumExpansionDimensions: 128
KernelScale: 1
Lambda: 0.01
BoxConstraint: 1
predict (Mdl, X([1, 51],:))
ans =
2x1 cell array
{'versicolor'}
{'virginica' }
The box constraint and the regularization strength are two names for the same quantity: setting either fixes the other.
load fisheriris X = meas(51:end,:); Y = species(51:end); Mdl = ClassificationKernel (X, Y, 'BoxConstraint', 4); Mdl.BoxConstraint
ans = 4
Mdl.Lambda
ans = 2.5000e-03
Either 'svm' or 'logistic'. This property is
read-only.
Separate the two overlapping iris species through a randomized Gaussian kernel, and read the model the fit produced.
load fisheriris X = meas(51:end,:); Y = species(51:end); Mdl = ClassificationKernel (X, Y)
Mdl =
ClassificationKernel
ResponseName: 'Y'
ClassNames: {'versicolor' 'virginica'}
Learner: 'svm'
NumExpansionDimensions: 128
KernelScale: 1
Lambda: 0.01
BoxConstraint: 1
predict (Mdl, X([1, 51],:))
ans =
2x1 cell array
{'versicolor'}
{'virginica' }
The box constraint and the regularization strength are two names for the same quantity: setting either fixes the other.
load fisheriris X = meas(51:end,:); Y = species(51:end); Mdl = ClassificationKernel (X, Y, 'BoxConstraint', 4); Mdl.BoxConstraint
ans = 4
Mdl.Lambda
ans = 2.5000e-03
A row vector with one element per predictor, or empty when the model was fitted without standardizing. This property is read-only.
Separate the two overlapping iris species through a randomized Gaussian kernel, and read the model the fit produced.
load fisheriris X = meas(51:end,:); Y = species(51:end); Mdl = ClassificationKernel (X, Y)
Mdl =
ClassificationKernel
ResponseName: 'Y'
ClassNames: {'versicolor' 'virginica'}
Learner: 'svm'
NumExpansionDimensions: 128
KernelScale: 1
Lambda: 0.01
BoxConstraint: 1
predict (Mdl, X([1, 51],:))
ans =
2x1 cell array
{'versicolor'}
{'virginica' }
The box constraint and the regularization strength are two names for the same quantity: setting either fixes the other.
load fisheriris X = meas(51:end,:); Y = species(51:end); Mdl = ClassificationKernel (X, Y, 'BoxConstraint', 4); Mdl.BoxConstraint
ans = 4
Mdl.Lambda
ans = 2.5000e-03
A row vector with one element per predictor, or empty when the model was fitted without standardizing. This property is read-only.
Separate the two overlapping iris species through a randomized Gaussian kernel, and read the model the fit produced.
load fisheriris X = meas(51:end,:); Y = species(51:end); Mdl = ClassificationKernel (X, Y)
Mdl =
ClassificationKernel
ResponseName: 'Y'
ClassNames: {'versicolor' 'virginica'}
Learner: 'svm'
NumExpansionDimensions: 128
KernelScale: 1
Lambda: 0.01
BoxConstraint: 1
predict (Mdl, X([1, 51],:))
ans =
2x1 cell array
{'versicolor'}
{'virginica' }
The box constraint and the regularization strength are two names for the same quantity: setting either fixes the other.
load fisheriris X = meas(51:end,:); Y = species(51:end); Mdl = ClassificationKernel (X, Y, 'BoxConstraint', 4); Mdl.BoxConstraint
ans = 4
Mdl.Lambda
ans = 2.5000e-03
The ClassificationKernel class offers the following public methods:
ClassificationKernel: obj = ClassificationKernel (X, Y)
ClassificationKernel: obj = ClassificationKernel (…, name, value)
obj = ClassificationKernel (X, Y) fits a
support vector machine in a randomized Gaussian kernel space to the
predictor matrix X and the response
Y, which must name exactly two classes.
obj = ClassificationKernel (…, name,
value) takes the following Name-Value pairs.
| Name | Value |
|---|---|
'Learner' | 'svm', the default, or
'logistic'. |
'NumExpansionDimensions' | 'auto', the
default, or a positive integer. |
'KernelScale' | 1 by default, a positive
scalar, or 'auto', which takes the median distance between the
observations. |
'Lambda' | 'auto', the default, which is the
reciprocal of the number of observations, or a nonnegative scalar. It
cannot be given beside 'BoxConstraint'. |
'BoxConstraint' | A positive scalar, 1 by
default. It applies to a support vector machine alone. |
'Standardize' | Whether to centre and scale the predictors, false by default. |
'BetaTolerance' | Relative tolerance on the
coefficients, 1e-4 by default. |
'GradientTolerance' | Absolute tolerance on the
gradient’s infinity norm, 1e-6 by default. |
'IterationLimit' | Largest number of iterations,
1000 by default. |
'HessianHistorySize' | Number of curvature pairs the
solver keeps, 15 by default. |
'BlockSize' | Memory the expansion may occupy, in
megabytes, 4e3 by default. |
'ClassNames' | The classes to keep, given in the type of Y. |
'Cost' | A square misclassification cost matrix. |
'Prior' | 'empirical', the default,
'uniform', a vector of probabilities, or a structure with
ClassNames and ClassProbs fields. |
'ScoreTransform' | A transformation applied to the scores, named or given as a function handle. |
'Weights' | One nonnegative weight per observation. |
'PredictorNames' | One name per predictor. |
'ResponseName' | A name for the response. |
'CategoricalPredictors' | Indices of the categorical predictors. |
The fit is always by limited-memory BFGS, the only solver MATLAB offers a kernel model, and always under a ridge penalty.
See also: fitckernel, ClassificationLinear
Separate the two overlapping iris species through a randomized Gaussian kernel, and read the model the fit produced.
load fisheriris X = meas(51:end,:); Y = species(51:end); Mdl = ClassificationKernel (X, Y)
Mdl =
ClassificationKernel
ResponseName: 'Y'
ClassNames: {'versicolor' 'virginica'}
Learner: 'svm'
NumExpansionDimensions: 128
KernelScale: 1
Lambda: 0.01
BoxConstraint: 1
predict (Mdl, X([1, 51],:))
ans =
2x1 cell array
{'versicolor'}
{'virginica' }
The box constraint and the regularization strength are two names for the same quantity: setting either fixes the other.
load fisheriris X = meas(51:end,:); Y = species(51:end); Mdl = ClassificationKernel (X, Y, 'BoxConstraint', 4); Mdl.BoxConstraint
ans = 4
Mdl.Lambda
ans = 2.5000e-03
ClassificationKernel: labels = predict (obj, XC)
ClassificationKernel: [labels, scores] = predict (obj, XC)
labels = predict (obj, XC) maps each row of
XC through the model’s own random basis and returns the class of
largest score.
[labels, scores] = predict (obj, XC)
also returns the scores, whose columns follow
ClassNames, after ScoreTransform has been applied.
Separate the two overlapping iris species through a randomized Gaussian kernel, and read the model the fit produced.
load fisheriris X = meas(51:end,:); Y = species(51:end); Mdl = ClassificationKernel (X, Y)
Mdl =
ClassificationKernel
ResponseName: 'Y'
ClassNames: {'versicolor' 'virginica'}
Learner: 'svm'
NumExpansionDimensions: 128
KernelScale: 1
Lambda: 0.01
BoxConstraint: 1
predict (Mdl, X([1, 51],:))
ans =
2x1 cell array
{'versicolor'}
{'virginica' }
The box constraint and the regularization strength are two names for the same quantity: setting either fixes the other.
load fisheriris X = meas(51:end,:); Y = species(51:end); Mdl = ClassificationKernel (X, Y, 'BoxConstraint', 4); Mdl.BoxConstraint
ans = 4
Mdl.Lambda
ans = 2.5000e-03
ClassificationKernel: m = margin (obj, X, Y)
m = margin (obj, X, Y) returns the
score of the true class less the score of the other one. A positive
margin is a correct classification.
Separate the two overlapping iris species through a randomized Gaussian kernel, and read the model the fit produced.
load fisheriris X = meas(51:end,:); Y = species(51:end); Mdl = ClassificationKernel (X, Y)
Mdl =
ClassificationKernel
ResponseName: 'Y'
ClassNames: {'versicolor' 'virginica'}
Learner: 'svm'
NumExpansionDimensions: 128
KernelScale: 1
Lambda: 0.01
BoxConstraint: 1
predict (Mdl, X([1, 51],:))
ans =
2x1 cell array
{'versicolor'}
{'virginica' }
The box constraint and the regularization strength are two names for the same quantity: setting either fixes the other.
load fisheriris X = meas(51:end,:); Y = species(51:end); Mdl = ClassificationKernel (X, Y, 'BoxConstraint', 4); Mdl.BoxConstraint
ans = 4
Mdl.Lambda
ans = 2.5000e-03
ClassificationKernel: e = edge (obj, X, Y)
ClassificationKernel: e = edge (…, 'Weights', W)
The weights are normalized within each class to that class’s prior before they are applied.
Separate the two overlapping iris species through a randomized Gaussian kernel, and read the model the fit produced.
load fisheriris X = meas(51:end,:); Y = species(51:end); Mdl = ClassificationKernel (X, Y)
Mdl =
ClassificationKernel
ResponseName: 'Y'
ClassNames: {'versicolor' 'virginica'}
Learner: 'svm'
NumExpansionDimensions: 128
KernelScale: 1
Lambda: 0.01
BoxConstraint: 1
predict (Mdl, X([1, 51],:))
ans =
2x1 cell array
{'versicolor'}
{'virginica' }
The box constraint and the regularization strength are two names for the same quantity: setting either fixes the other.
load fisheriris X = meas(51:end,:); Y = species(51:end); Mdl = ClassificationKernel (X, Y, 'BoxConstraint', 4); Mdl.BoxConstraint
ans = 4
Mdl.Lambda
ans = 2.5000e-03
ClassificationKernel: l = loss (obj, X, Y)
ClassificationKernel: l = loss (…, name, value)
l = loss (obj, X, Y) returns the
misclassification rate.
l = loss (…, name, value) takes
'LossFun', one of 'binodeviance',
'classifcost', 'classiferror', 'exponential',
'hinge', 'logit', 'mincost' and
'quadratic', and 'Weights'.
Separate the two overlapping iris species through a randomized Gaussian kernel, and read the model the fit produced.
load fisheriris X = meas(51:end,:); Y = species(51:end); Mdl = ClassificationKernel (X, Y)
Mdl =
ClassificationKernel
ResponseName: 'Y'
ClassNames: {'versicolor' 'virginica'}
Learner: 'svm'
NumExpansionDimensions: 128
KernelScale: 1
Lambda: 0.01
BoxConstraint: 1
predict (Mdl, X([1, 51],:))
ans =
2x1 cell array
{'versicolor'}
{'virginica' }
The box constraint and the regularization strength are two names for the same quantity: setting either fixes the other.
load fisheriris X = meas(51:end,:); Y = species(51:end); Mdl = ClassificationKernel (X, Y, 'BoxConstraint', 4); Mdl.BoxConstraint
ans = 4
Mdl.Lambda
ans = 2.5000e-03
ClassificationKernel: obj = resume (obj, X, Y)
ClassificationKernel: obj = resume (…, name, value)
obj = resume (obj, X, Y) restarts the
optimization from the coefficients the model already carries, through
the basis it already holds, and returns the model it reaches. It
takes 'BetaTolerance', 'GradientTolerance' and
'IterationLimit', each defaulting to what the model was
fitted with, and 'Weights'.
X and Y must be the data the model was fitted to; the
object keeps no copy of them, which is what makes it small. Neither
does it keep the observation weights, so a model fitted with
'Weights' must be given them again here or it will resume
against uniform ones. MATLAB behaves the same way: measured on
R2024a, resuming a weighted fit without passing the weights back
reaches the objective of the unweighted fit.
Separate the two overlapping iris species through a randomized Gaussian kernel, and read the model the fit produced.
load fisheriris X = meas(51:end,:); Y = species(51:end); Mdl = ClassificationKernel (X, Y)
Mdl =
ClassificationKernel
ResponseName: 'Y'
ClassNames: {'versicolor' 'virginica'}
Learner: 'svm'
NumExpansionDimensions: 128
KernelScale: 1
Lambda: 0.01
BoxConstraint: 1
predict (Mdl, X([1, 51],:))
ans =
2x1 cell array
{'versicolor'}
{'virginica' }
The box constraint and the regularization strength are two names for the same quantity: setting either fixes the other.
load fisheriris X = meas(51:end,:); Y = species(51:end); Mdl = ClassificationKernel (X, Y, 'BoxConstraint', 4); Mdl.BoxConstraint
ans = 4
Mdl.Lambda
ans = 2.5000e-03
ClassificationKernel: savemodel (obj, filename)
savemodel (obj, filename) saves the model
obj into filename in a form loadmodel can read
back, the random basis included.
Separate the two overlapping iris species through a randomized Gaussian kernel, and read the model the fit produced.
load fisheriris X = meas(51:end,:); Y = species(51:end); Mdl = ClassificationKernel (X, Y)
Mdl =
ClassificationKernel
ResponseName: 'Y'
ClassNames: {'versicolor' 'virginica'}
Learner: 'svm'
NumExpansionDimensions: 128
KernelScale: 1
Lambda: 0.01
BoxConstraint: 1
predict (Mdl, X([1, 51],:))
ans =
2x1 cell array
{'versicolor'}
{'virginica' }
The box constraint and the regularization strength are two names for the same quantity: setting either fixes the other.
load fisheriris X = meas(51:end,:); Y = species(51:end); Mdl = ClassificationKernel (X, Y, 'BoxConstraint', 4); Mdl.BoxConstraint
ans = 4
Mdl.Lambda
ans = 2.5000e-03
load fisheriris X = meas(51:end,:); Y = species(51:end); Mdl = ClassificationKernel (X, Y)
Mdl =
ClassificationKernel
ResponseName: 'Y'
ClassNames: {'versicolor' 'virginica'}
Learner: 'svm'
NumExpansionDimensions: 128
KernelScale: 1
Lambda: 0.01
BoxConstraint: 1
predict (Mdl, X([1, 51],:))
ans =
2x1 cell array
{'versicolor'}
{'virginica' }
load fisheriris X = meas(51:end,:); Y = species(51:end); Mdl = ClassificationKernel (X, Y, 'BoxConstraint', 4); Mdl.BoxConstraint
ans = 4
Mdl.Lambda
ans = 2.5000e-03