Skip to contents

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

Dictionary

This Learner can be instantiated via lrn():

lrn("classif.sgd")

Meta Information

  • Task type: “classif”

  • Predict Types: “response”, “prob”

  • Feature Types: “logical”, “integer”, “numeric”, “factor”, “ordered”

  • Required Packages: mlr3, RWeka

Parameters

IdTypeDefaultLevelsRange
subsetuntyped--
na.actionuntyped--
Fcharacter00, 1-
Lnumeric0.01\((-\infty, \infty)\)
Rnumeric1e-04\((-\infty, \infty)\)
Einteger500\((-\infty, \infty)\)
Cnumeric0.001\((-\infty, \infty)\)
Nlogical-TRUE, FALSE-
Mlogical-TRUE, FALSE-
Sinteger1\((-\infty, \infty)\)
output_debug_infologicalFALSETRUE, FALSE-
do_not_check_capabilitieslogicalFALSETRUE, FALSE-
num_decimal_placesinteger2\([1, \infty)\)
batch_sizeinteger100\([1, \infty)\)
optionsuntypedNULL-

See also

Author

damirpolat

Super classes

mlr3::Learner -> mlr3::LearnerClassif -> LearnerClassifSGD

Methods

Inherited methods


Method new()

Creates a new instance of this R6 class.

Usage


Method clone()

The objects of this class are cloneable with this method.

Usage

LearnerClassifSGD$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

# Define the Learner
learner = mlr3::lrn("classif.sgd")
print(learner)
#> <LearnerClassifSGD:classif.sgd>: Stochastic Gradient Descent
#> * Model: -
#> * Parameters: F=0
#> * Packages: mlr3, RWeka
#> * Predict Types:  [response], prob
#> * Feature Types: logical, integer, numeric, factor, ordered
#> * Properties: missings, twoclass

# 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 = 
#> 
#>         -2.1733 (normalized) V1
#>  +      -0.1931 (normalized) V10
#>  +      -3.4259 (normalized) V11
#>  +      -3.7053 (normalized) V12
#>  +       0.3851 (normalized) V13
#>  +       0.9913 (normalized) V14
#>  +       0.927  (normalized) V15
#>  +       1.6153 (normalized) V16
#>  +       2.0116 (normalized) V17
#>  +      -0.5851 (normalized) V18
#>  +      -1.8664 (normalized) V19
#>  +      -0.7009 (normalized) V2
#>  +       0.6537 (normalized) V20
#>  +      -0.0141 (normalized) V21
#>  +      -1.176  (normalized) V22
#>  +      -0.7539 (normalized) V23
#>  +      -1.9886 (normalized) V24
#>  +       0.2561 (normalized) V25
#>  +       1.5919 (normalized) V26
#>  +       0.1103 (normalized) V27
#>  +      -1.3986 (normalized) V28
#>  +       0.5049 (normalized) V29
#>  +       1.1809 (normalized) V3
#>  +      -1.1902 (normalized) V30
#>  +       2.0676 (normalized) V31
#>  +       0.1588 (normalized) V32
#>  +       0.8817 (normalized) V33
#>  +      -0.2278 (normalized) V34
#>  +      -1.9539 (normalized) V35
#>  +       2.0625 (normalized) V36
#>  +       3.4388 (normalized) V37
#>  +      -2.0794 (normalized) V38
#>  +      -0.1892 (normalized) V39
#>  +      -1.6353 (normalized) V4
#>  +       1.5751 (normalized) V40
#>  +      -1.2118 (normalized) V41
#>  +       2.1383 (normalized) V42
#>  +       0.054  (normalized) V43
#>  +      -2.4919 (normalized) V44
#>  +      -1.9036 (normalized) V45
#>  +      -0.5717 (normalized) V46
#>  +       0.1287 (normalized) V47
#>  +      -1.518  (normalized) V48
#>  +      -2.7198 (normalized) V49
#>  +      -0.1848 (normalized) V5
#>  +       2.6248 (normalized) V50
#>  +       0.4506 (normalized) V51
#>  +      -3.6345 (normalized) V52
#>  +      -0.448  (normalized) V53
#>  +      -0.4525 (normalized) V54
#>  +       0.3362 (normalized) V55
#>  +       0.6106 (normalized) V56
#>  +       1.3512 (normalized) V57
#>  +      -3.0745 (normalized) V58
#>  +      -1.7404 (normalized) V59
#>  +      -0.3576 (normalized) V6
#>  +      -0.636  (normalized) V60
#>  +       0.452  (normalized) V7
#>  +       1.6117 (normalized) V8
#>  +      -0.2569 (normalized) V9
#>  +       4.51  


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

# Score the predictions
predictions$score()
#> classif.ce 
#>  0.2753623