mlr_learners_classif.log_reg {mlr3learners}R Documentation

Logistic Regression Classification Learner

Description

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

Dictionary

This mlr3::Learner can be instantiated via the dictionary mlr3::mlr_learners or with the associated sugar function mlr3::lrn():

mlr_learners$get("classif.log_reg")
lrn("classif.log_reg")

Meta Information

Parameters

Id Type Default Levels Range
dispersion untyped NULL -
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 NULL -
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:

Setting the option "contrasts" does not have any effect. Instead, set the respective hyperparameter or use mlr3pipelines to create dummy features.

Super classes

mlr3::Learner -> mlr3::LearnerClassif -> LearnerClassifLogReg

Methods

Public methods

Inherited methods

Method new()

Creates a new instance of this R6 class.

Usage
LearnerClassifLogReg$new()

Method loglik()

Extract the log-likelihood (e.g., via stats::logLik() from the fitted model.

Usage
LearnerClassifLogReg$loglik()

Method clone()

The objects of this class are cloneable with this method.

Usage
LearnerClassifLogReg$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

See Also

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

Examples

if (requireNamespace("stats", quietly = TRUE)) {
# Define the Learner and set parameter values
learner = lrn("classif.log_reg")
print(learner)

# Define a Task
task = tsk("sonar")

# Create train and test set
ids = partition(task)

# Train the learner on the training ids
learner$train(task, row_ids = ids$train)

# print the model
print(learner$model)

# importance method
if("importance" %in% learner$properties) print(learner$importance)

# Make predictions for the test rows
predictions = learner$predict(task, row_ids = ids$test)

# Score the predictions
predictions$score()
}

[Package mlr3learners version 0.7.0 Index]