Classification Stochastic Gradient Descent Learner
mlr_learners_classif.sgd.Rd
Stochastic Gradient Descent for learning various linear models.
Calls RWeka::make_Weka_classifier()
from RWeka.
Initial parameter values
F
:Has only 2 out of 5 original loss functions: 0 = hinge loss (SVM) and 1 = log loss (logistic regression) with 0 (hinge loss) still being the default
Reason for change: this learner should only contain loss functions appropriate for classification tasks
Custom mlr3 parameters
output_debug_info
:original id: output-debug-info
do_not_check_capabilities
:original id: do-not-check-capabilities
num_decimal_places
:original id: num-decimal-places
batch_size
:original id: batch-size
Reason for change: This learner contains changed ids of the following control arguments since their ids contain irregular pattern
Parameters
Id | Type | Default | Levels | Range |
subset | untyped | - | - | |
na.action | untyped | - | - | |
F | character | 0 | 0, 1 | - |
L | numeric | 0.01 | \((-\infty, \infty)\) | |
R | numeric | 1e-04 | \((-\infty, \infty)\) | |
E | integer | 500 | \((-\infty, \infty)\) | |
C | numeric | 0.001 | \((-\infty, \infty)\) | |
N | logical | - | TRUE, FALSE | - |
M | logical | - | TRUE, FALSE | - |
S | integer | 1 | \((-\infty, \infty)\) | |
output_debug_info | logical | FALSE | TRUE, FALSE | - |
do_not_check_capabilities | logical | FALSE | TRUE, FALSE | - |
num_decimal_places | integer | 2 | \([1, \infty)\) | |
batch_size | integer | 100 | \([1, \infty)\) | |
options | untyped | NULL | - |
See also
as.data.table(mlr_learners)
for a table of available Learners in the running session (depending on the loaded packages).Chapter in the mlr3book: https://mlr3book.mlr-org.com/basics.html#learners
mlr3learners for a selection of recommended learners.
mlr3cluster for unsupervised clustering learners.
mlr3pipelines to combine learners with pre- and postprocessing steps.
mlr3tuning for tuning of hyperparameters, mlr3tuningspaces for established default tuning spaces.
Super classes
mlr3::Learner
-> mlr3::LearnerClassif
-> LearnerClassifSGD
Examples
# Define the Learner
learner = mlr3::lrn("classif.sgd")
print(learner)
#>
#> ── <LearnerClassifSGD> (classif.sgd): Stochastic Gradient Descent ──────────────
#> • Model: -
#> • Parameters: F=0
#> • Packages: mlr3 and RWeka
#> • Predict Types: [response] and prob
#> • Feature Types: logical, integer, numeric, factor, and ordered
#> • Encapsulation: none (fallback: -)
#> • Properties: missings and twoclass
#> • Other settings: use_weights = 'error'
# Define a Task
task = mlr3::tsk("sonar")
# Create train and test set
ids = mlr3::partition(task)
# Train the learner on the training ids
learner$train(task, row_ids = ids$train)
print(learner$model)
#> Loss function: Hinge loss (SVM)
#>
#> Class =
#>
#> -0.7346 (normalized) V1
#> + -1.7841 (normalized) V10
#> + -1.1023 (normalized) V11
#> + -1.9158 (normalized) V12
#> + -1.9504 (normalized) V13
#> + 0.5573 (normalized) V14
#> + 0.5091 (normalized) V15
#> + 3.0395 (normalized) V16
#> + 1.6735 (normalized) V17
#> + 0.4114 (normalized) V18
#> + -0.957 (normalized) V19
#> + -0.4664 (normalized) V2
#> + -0.6562 (normalized) V20
#> + -0.7603 (normalized) V21
#> + -1.2069 (normalized) V22
#> + -1.1724 (normalized) V23
#> + -0.7881 (normalized) V24
#> + 1.2736 (normalized) V25
#> + 1.1049 (normalized) V26
#> + -1.4597 (normalized) V27
#> + 0.2752 (normalized) V28
#> + -0.2917 (normalized) V29
#> + 0.3712 (normalized) V3
#> + -1.4876 (normalized) V30
#> + 2.8814 (normalized) V31
#> + -0.8086 (normalized) V32
#> + 0.9691 (normalized) V33
#> + -0.0772 (normalized) V34
#> + -0.6211 (normalized) V35
#> + 1.8683 (normalized) V36
#> + 0.4124 (normalized) V37
#> + 0.0934 (normalized) V38
#> + -0.424 (normalized) V39
#> + -1.0038 (normalized) V4
#> + 2.5093 (normalized) V40
#> + -0.2681 (normalized) V41
#> + 0.0269 (normalized) V42
#> + -1.2142 (normalized) V43
#> + -1.9248 (normalized) V44
#> + -0.735 (normalized) V45
#> + 0.0659 (normalized) V46
#> + -0.4827 (normalized) V47
#> + -0.285 (normalized) V48
#> + -2.9215 (normalized) V49
#> + -1.1722 (normalized) V5
#> + 1.795 (normalized) V50
#> + -2.0655 (normalized) V51
#> + -1.2559 (normalized) V52
#> + 0.3861 (normalized) V53
#> + 0.2354 (normalized) V54
#> + 3.4965 (normalized) V55
#> + -0.9008 (normalized) V56
#> + 0.01 (normalized) V57
#> + -2.1571 (normalized) V58
#> + -0.4753 (normalized) V59
#> + -1.9947 (normalized) V6
#> + -0.1471 (normalized) V60
#> + -0.2373 (normalized) V7
#> + 2.4032 (normalized) V8
#> + -2.8721 (normalized) V9
#> + 3.96
# Make predictions for the test rows
predictions = learner$predict(task, row_ids = ids$test)
# Score the predictions
predictions$score()
#> classif.ce
#> 0.2608696