MultinomialClassifier
MultinomialClassifierA model type for constructing a multinomial classifier, based on MLJLinearModels.jl, and implementing the MLJ model interface.
From MLJ, the type can be imported using
MultinomialClassifier = @load MultinomialClassifier pkg=MLJLinearModelsDo model = MultinomialClassifier() to construct an instance with default hyper-parameters.
This model coincides with LogisticClassifier, except certain optimizations possible in the special binary case will not be applied. Its hyperparameters are identical.
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 is<:OrderedFactoror<:Multiclass; check the scitype withscitype(y)
Train the machine using fit!(mach, rows=...).
Hyperparameters
lambda::Real: strength of the regularizer ifpenaltyis:l2or:l1. Strength of the L2 regularizer ifpenaltyis:en. Default: eps()gamma::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 samples. Default: truesolver::Union{Nothing, MLJLinearModels.Solver}: some instance ofMLJLinearModels.SwhereSis one of:LBFGS,NewtonCG,ProxGrad; but subject to the following restrictions:- If
penalty = :l2,ProxGradis disallowed. Otherwise,ProxGradis the only option. - Unless
scitype(y) <: Finite{2}(binary target)Newtonis disallowed.
If
solver = nothing(default) thenProxGrad(accel=true)(FISTA) is used, unlessgamma = 0, in which caseLBFGS()is used.Solver aliases:
FISTA(; kwargs...) = ProxGrad(accel=true, kwargs...),ISTA(; kwargs...) = ProxGrad(accel=false, kwargs...)Default: nothing- If
Example
using MLJ
X, y = make_blobs(centers = 3)
mach = fit!(machine(MultinomialClassifier(), X, y))
predict(mach, X)
fitted_params(mach)See also LogisticClassifier.