LinearRegressor
LinearRegressor
A model type for constructing a linear regressor, based on MLJLinearModels.jl, and implementing the MLJ model interface.
From MLJ, the type can be imported using
LinearRegressor = @load LinearRegressor pkg=MLJLinearModels
Do model = LinearRegressor()
to construct an instance with default hyper-parameters.
This model provides standard linear regression with objective function
$
|Xθ - y|₂²/2 $
Different solver options exist, as indicated under "Hyperparameters" below.
Training data
In MLJ or MLJBase, bind an instance model
to data with
mach = machine(model, X, y)
where:
X
is any table of input features (eg, aDataFrame
) whose columns haveContinuous
scitype; check column scitypes withschema(X)
y
is the target, which can be anyAbstractVector
whose element scitype isContinuous
; check the scitype withscitype(y)
Train the machine using fit!(mach, rows=...)
.
Hyperparameters
fit_intercept::Bool
: whether to fit the intercept or not. Default: truesolver::Union{Nothing, MLJLinearModels.Solver}
: "any instance ofMLJLinearModels.Analytical
. UseAnalytical()
for Cholesky andCG()=Analytical(iterative=true)
for conjugate-gradient.If
solver = nothing
(default) thenAnalytical()
is used. Default: nothing
Example
using MLJ
X, y = make_regression()
mach = fit!(machine(LinearRegressor(), X, y))
predict(mach, X)
fitted_params(mach)