Logistic Regression Classification Learner
Source:R/LearnerClassifLogReg.R
mlr_learners_classif.log_reg.Rd
Classification via logistic regression.
Calls stats::glm()
with family
set to "binomial"
.
Internal Encoding
Starting with mlr3 v0.5.0, the order of class labels is reversed prior to
model fitting to comply to the stats::glm()
convention that the negative class is provided
as the first factor level.
Weights
It is not advisable to change the weights of a logistic regression. For more details, see this question on Cross Validated.
Initial parameter values
model
:Actual default:
TRUE
.Adjusted default:
FALSE
.Reason for change: Save some memory.
Dictionary
This Learner can be instantiated via the dictionary mlr_learners or with the associated sugar function lrn()
:
$get("classif.log_reg")
mlr_learnerslrn("classif.log_reg")
Meta Information
Task type: “classif”
Predict Types: “response”, “prob”
Feature Types: “logical”, “integer”, “numeric”, “character”, “factor”, “ordered”
Required Packages: mlr3, mlr3learners, 'stats'
Parameters
Id | Type | Default | Levels | Range |
dispersion | untyped | - | ||
epsilon | numeric | 1e-08 | \((-\infty, \infty)\) | |
etastart | untyped | - | - | |
maxit | numeric | 25 | \((-\infty, \infty)\) | |
model | logical | TRUE | TRUE, FALSE | - |
mustart | untyped | - | - | |
offset | untyped | - | - | |
singular.ok | logical | TRUE | TRUE, FALSE | - |
start | untyped | - | ||
trace | logical | FALSE | TRUE, FALSE | - |
x | logical | FALSE | TRUE, FALSE | - |
y | logical | TRUE | TRUE, FALSE | - |
Contrasts
To ensure reproducibility, this learner always uses the default contrasts:
contr.treatment()
for unordered factors, andcontr.poly()
for ordered factors.
Setting the option "contrasts"
does not have any effect.
Instead, set the respective hyperparameter or use mlr3pipelines to create dummy features.
See also
Chapter in the mlr3book: https://mlr3book.mlr-org.com/chapters/chapter2/data_and_basic_modeling.html#sec-learners
Package mlr3extralearners for more learners.
Dictionary of Learners: mlr_learners
as.data.table(mlr_learners)
for a table of available Learners in the running session (depending on the loaded packages).mlr3pipelines to combine learners with pre- and postprocessing steps.
Extension packages for additional task types:
mlr3proba for probabilistic supervised regression and survival analysis.
mlr3cluster for unsupervised clustering.
mlr3tuning for tuning of hyperparameters, mlr3tuningspaces for established default tuning spaces.
Other Learner:
mlr_learners_classif.cv_glmnet
,
mlr_learners_classif.glmnet
,
mlr_learners_classif.kknn
,
mlr_learners_classif.lda
,
mlr_learners_classif.multinom
,
mlr_learners_classif.naive_bayes
,
mlr_learners_classif.nnet
,
mlr_learners_classif.qda
,
mlr_learners_classif.ranger
,
mlr_learners_classif.svm
,
mlr_learners_classif.xgboost
,
mlr_learners_regr.cv_glmnet
,
mlr_learners_regr.glmnet
,
mlr_learners_regr.kknn
,
mlr_learners_regr.km
,
mlr_learners_regr.lm
,
mlr_learners_regr.nnet
,
mlr_learners_regr.ranger
,
mlr_learners_regr.svm
,
mlr_learners_regr.xgboost
Super classes
mlr3::Learner
-> mlr3::LearnerClassif
-> LearnerClassifLogReg
Methods
Method loglik()
Extract the log-likelihood (e.g., via stats::logLik()
from the fitted model.
Examples
if (requireNamespace("stats", quietly = TRUE)) {
learner = mlr3::lrn("classif.log_reg")
print(learner)
# available parameters:
learner$param_set$ids()
}
#> <LearnerClassifLogReg:classif.log_reg>: Logistic Regression
#> * Model: -
#> * Parameters: list()
#> * Packages: mlr3, mlr3learners, stats
#> * Predict Types: [response], prob
#> * Feature Types: logical, integer, numeric, character, factor, ordered
#> * Properties: loglik, twoclass
#> [1] "dispersion" "epsilon" "etastart" "maxit" "model"
#> [6] "mustart" "offset" "singular.ok" "start" "trace"
#> [11] "x" "y"