fitclinear
statistics: Mdl = fitclinear (X, Y)
statistics: Mdl = fitclinear (…, name, value)
statistics: [Mdl, FitInfo] = fitclinear (…)
Fit a linear binary classifier.
Mdl = fitclinear (X, Y) returns a
ClassificationLinear object fitted to the predictor data X
and the two class response Y, where X is an
numeric matrix and Y has as many rows as X.
Mdl = fitclinear (…, name, value) passes
the given Name-Value pairs to the model. They are documented
under ClassificationLinear, and the ones most often wanted are
'Learner', 'Regularization', 'Lambda',
'Solver' and 'ObservationsIn'.
[Mdl, FitInfo] = fitclinear (…) also returns a
structure describing the optimization: what it converged to, how far it
got, and which tolerance stopped it. Its fields follow the solver, so a
dual fit reports the dual variables and a mini-batch fit the batch it
stopped on.
Mdl = fitclinear (…, cvopt, value) returns a
ClassificationPartitionedLinear
instead when one of 'CrossVal', 'KFold',
'Holdout', 'Leaveout' and 'CVPartition' is
given. A cross-validated model describes no single fit, so
FitInfo is not available beside it.
See also: ClassificationLinear, ClassificationKernel, fitckernel
Source Code: fitclinear
Fit a linear classifier to the two overlapping iris species and read what the optimization did.
load fisheriris X = meas(51:end,:); Y = species(51:end); [Mdl, FitInfo] = fitclinear (X, Y, 'Learner', 'logistic')
Mdl =
ClassificationLinear
ResponseName: 'Y'
ClassNames: {'versicolor' 'virginica'}
ScoreTransform: 'logit'
Beta: [4x1 double]
Bias: -14.4308
Lambda: 0.01
Learner: 'logistic'
FitInfo =
scalar structure containing the fields:
Lambda = 0.010000
Objective = 0.2405
IterationLimit = 1000
NumIterations = 24
GradientNorm = 1.0166e-05
GradientTolerance = 1.0000e-06
RelativeChangeInBeta = 2.5219e-05
BetaTolerance = 1.0000e-04
DeltaGradient = [](0x0)
DeltaGradientTolerance = [](0x0)
TerminationCode = 1
TerminationStatus =
{
[1,1] = Tolerance on coefficients satisfied.
}
History = [](0x0)
FitTime = 0
Solver =
{
[1,1] = bfgs
}