RobustRegressor
RobustRegressorA model type for constructing a robust regressor, based on MLJLinearModels.jl, and implementing the MLJ model interface.
From MLJ, the type can be imported using
RobustRegressor = @load RobustRegressor pkg=MLJLinearModelsDo model = RobustRegressor() to construct an instance with default hyper-parameters.
Robust regression is a linear model with objective function
$
∑ρ(Xθ - y) + n⋅λ|θ|₂² + n⋅γ|θ|₁ $
where $ρ$ is a robust loss function (e.g. the Huber function) and $n$ is the number of observations.
If scale_penalty_with_samples = false the objective function is instead
$
∑ρ(Xθ - y) + λ|θ|₂² + γ|θ|₁ $
.
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:
Xis any table of input features (eg, aDataFrame) whose columns haveContinuousscitype; check column scitypes withschema(X)yis the target, which can be anyAbstractVectorwhose element scitype isContinuous; check the scitype withscitype(y)
Train the machine using fit!(mach, rows=...).
Hyperparameters
rho::MLJLinearModels.RobustRho: the type of robust loss, which can be any instance ofMLJLinearModels.LwhereLis one of:AndrewsRho,BisquareRho,FairRho,HuberRho,LogisticRho,QuantileRho,TalwarRho,HuberRho,TalwarRho. Default: HuberRho(0.1)lambda::Real: strength of the regularizer ifpenaltyis:l2or:l1. Strength of the L2 regularizer ifpenaltyis:en. Default: 1.0gamma::Real: strength of the L1 regularizer ifpenaltyis:en. Default: 0.0penalty::Union{String, Symbol}: the penalty to use, either:l2,:l1,:en(elastic net) or:none. Default: :l2fit_intercept::Bool: whether to fit the intercept or not. Default: truepenalize_intercept::Bool: whether to penalize the intercept. Default: falsescale_penalty_with_samples::Bool: whether to scale the penalty with the number of observations. Default: truesolver::Union{Nothing, MLJLinearModels.Solver}: some instance ofMLJLinearModels.SwhereSis one of:LBFGS,IWLSCG,Newton,NewtonCG, ifpenalty = :l2, andProxGradotherwise.If
solver = nothing(default) thenLBFGS()is used, ifpenalty = :l2, and otherwiseProxGrad(accel=true)(FISTA) is used.Solver aliases:
FISTA(; kwargs...) = ProxGrad(accel=true, kwargs...),ISTA(; kwargs...) = ProxGrad(accel=false, kwargs...)Default: nothing
Example
using MLJ
X, y = make_regression()
mach = fit!(machine(RobustRegressor(), X, y))
predict(mach, X)
fitted_params(mach)See also HuberRegressor, QuantileRegressor.