fitrlinear
statistics: Mdl = fitrlinear (X, Y)
statistics: Mdl = fitrlinear (…, name, value)
statistics: [Mdl, FitInfo] = fitrlinear (…)
Fit a linear regression model.
Mdl = fitrlinear (X, Y) returns a
RegressionLinear object fitted to the predictor data X and
the continuous response Y, where X is an numeric
matrix and Y an numeric vector with as many rows as
X.
Mdl = fitrlinear (…, name, value) passes
the given Name-Value pairs to the model. They are documented
under RegressionLinear, and the ones most often wanted are
'Learner', 'Epsilon', 'Regularization',
'Lambda' and 'Solver'.
[Mdl, FitInfo] = fitrlinear (…) 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 = fitrlinear (…, cvopt, value) returns a
RegressionPartitionedLinear
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: RegressionLinear, RegressionKernel, fitrkernel
Source Code: fitrlinear
Fit a linear regression to fuel consumption and read what the optimization did.
load carsmall X = [Acceleration, Displacement, Horsepower, Weight]; ok = ! any (isnan ([X, MPG]), 2); [Mdl, FitInfo] = fitrlinear (X(ok,:), MPG(ok), 'Learner', 'leastsquares')
Mdl =
RegressionLinear
ResponseName: 'Y'
ResponseTransform: 'none'
Beta: [4x1 double]
Bias: 23.7258
Lambda: 0.0107527
Learner: 'leastsquares'
FitInfo =
scalar structure containing the fields:
Lambda = 0.010753
Objective = 30.632
IterationLimit = 1000
NumIterations = 1
GradientNorm = 310.02
GradientTolerance = 1.0000e-06
RelativeChangeInBeta = 2.4921e-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
}