API
Regressors
EvoLinear.EvoLinearRegressor Type
EvoLinearRegressor(; kwargs...)A model type for constructing a EvoLinearRegressor, based on EvoLinear.jl, and implementing both an internal API and the MLJ model interface.
Keyword arguments
loss=:mse: loss function to be minimised. Can be one of::mse:logloss:poisson:gamma:tweedie
metric: The evaluation metric used to track evaluation data and serves as a basis for early stopping. Supported metrics are::mse: Mean squared error. Adapted for general regression models.:rmse: Root mean squared error. Adapted for general regression models.:mae: Mean absolute error. Adapted for general regression models.:logloss: Adapted forlogisticregression models.:poisson: Poisson deviance. Adapted for count models.:gamma: Gamma deviance. Adapted to regression problem on Gamma like, positively distributed targets.:tweedie: Tweedie deviance. Adapted to regression problem on Tweedie like, positively distributed targets with probability mass aty == 0.
nrounds=10: maximum number of training rounds.eta=1: Learning rate. Typically in the range[1e-2, 1].L1=0: Regularization penalty applied by shrinking to 0 weight update if update is < L1. No penalty if update > L1. Results in sparse feature selection. Typically in the[0, 1]range on normalized features.L2=0: Regularization penalty applied to the squared of the weight update value. Restricts large parameter values. Typically in the[0, 1]range on normalized features.seed::Int=123: random seed.updater=:all: training method. Only:allis supported at the moment. Gradients for each feature are computed simultaneously, then bias is updated based on all features update.
Internal API
Use config = EvoLinearRegressor() to construct an hyper-parameter struct with default hyper-parameters. Provide keyword arguments as listed above to override defaults, for example:
EvoLinearRegressor(loss=:logloss, L1=1e-3, L2=1e-2, nrounds=100)Training model
A model is built using fit:
config = EvoLinearRegressor()
m = fit(config, date; feature_names, target_name)Inference
Fitted results is an EvoLinearModel which acts as a prediction function when passed a features matrix as argument.
preds = m(x)MLJ Interface
From MLJ, the type can be imported using:
EvoLinearRegressor = @load EvoLinearRegressor pkg=EvoLinearDo model = EvoLinearRegressor() to construct an instance with default hyper-parameters. Provide keyword arguments to override hyper-parameter defaults, as in EvoLinearRegressor(loss=...).
Training model
In MLJ or MLJBase, bind an instance model to data with mach = machine(model, X, y) where:
X: any table of input features (eg, aDataFrame) whose columns each have one of the following element scitypes:Continuous,Count, or<:OrderedFactor; check column scitypes withschema(X)y: is the target, which can be anyAbstractVectorwhose element scitype is<:Continuous; check the scitype withscitype(y)
Train the machine using fit!(mach, rows=...).
Operations
predict(mach, Xnew): return predictions of the target given
features Xnew having the same scitype as X above. Predictions are deterministic.
Fitted parameters
The fields of fitted_params(mach) are:
:fitresult: theEvoLinearModelobject returned by EvoLnear.jl fitting algorithm.
Report
The fields of report(mach) are:
:coef: Vector of coefficients (βs) associated to each of the features.:bias: Value of the bias.:names: Names of each of the features.
Training
MLJModelInterface.fit Function
function fit(
learner::EvoLinearRegressor,
dtrain;
feature_names,
target_name,
weight_name=nothing,
deval=nothing,
metric=nothing,
print_every_n=9999,
early_stopping_rounds=9999,
verbosity=1
)Provided a config, EvoLinear.fit takes x and y as features and target inputs, plus optionally w as weights and train a Linear boosted model.
Arguments
learner::EvoLinearRegressor:dtrain: ATables.jlcompatible table containing the feature, target and optionally weight variables.
Keyword arguments
`target_name:
`feature_names=nothing:
`weight_name=nothing:
`deval=nothing:
`print_every_n=9999:
`verbosity=1:
Inference
MLJModelInterface.predict Function
predict(m::EvoLinearModel, data; proj::Bool=true)Predictions from an EvoLinear model.
sourceMetrics
EvoLinear.Metrics.gamma_deviance Method
gamma_deviance(p, y)
gamma_deviance(p, y, w)Gamma deviance evaluation metric. 𝐷 = 2 * (log(μ/y) + y/μ - 1)
Arguments
p: predicted value. Assumes that p is on a projected basis (ie. in the[0-Inf]range).y: observed target variable.w: vector of weights.
EvoLinear.Metrics.logloss Method
logloss(p, y)
logloss(p, y, w)Logloss evaluation metric. ylog(p) + (1-y)log(1-p)
Arguments
p: predicted value. Assumes that p is on a projected basis (ie. in the[0-1]range).y: observed target variable.w: vector of weights.
EvoLinear.Metrics.mae Method
mae(p, y)
mae(p, y, w)Mean absolute error evaluation metric.
Arguments
p: predicted value.y: observed target variable.w: vector of weights.
EvoLinear.Metrics.mse Method
mse(p, y)
mse(p, y, w)Mean squared error evaluation metric.
Arguments
p: predicted value.y: observed target variable.w: vector of weights.
EvoLinear.Metrics.poisson_deviance Method
poisson_deviance(p, y)
poisson_deviance(p, y, w)Poisson deviance evaluation metric. 𝐷 = 2 * (y * log(y/p) + p - y)
Arguments
p: predicted value. Assumes that p is on a projected basis (ie. in the[0-Inf]range).y: observed target variable.w: vector of weights.
EvoLinear.Metrics.rmse Method
rmse(p, y)
rmse(p, y, w)Root-Mean squared error evaluation metric.
Arguments
p: predicted value.y: observed target variable.w: vector of weights
EvoLinear.Metrics.tweedie_deviance Method
tweedie_deviance(p, y)
tweedie_deviance(p, y, w)Tweedie deviance evaluation metric. Fixed rho (ρ) of 1.5. 𝐷 = 2 * (y²⁻ʳʰᵒ/(1-rho)(2-rho) - yμ¹⁻ʳʰᵒ/(1-rho) + μ²⁻ʳʰᵒ/(2-rho))
Arguments
p: predicted value. Assumes that p is on a projected basis (ie. in the[0-Inf]range).y: observed target variable.w: vector of weights.