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 = 
#> 
#>         -0.2877 (normalized) V1
#>  +      -1.3762 (normalized) V10
#>  +      -3.7037 (normalized) V11
#>  +      -2.4266 (normalized) V12
#>  +       0.8814 (normalized) V13
#>  +       1.5089 (normalized) V14
#>  +       0.6586 (normalized) V15
#>  +       1.8386 (normalized) V16
#>  +       1.6928 (normalized) V17
#>  +       0.5864 (normalized) V18
#>  +       0.6962 (normalized) V19
#>  +       1.1814 (normalized) V2
#>  +      -1.1994 (normalized) V20
#>  +      -1.2622 (normalized) V21
#>  +      -0.2239 (normalized) V22
#>  +      -2.2905 (normalized) V23
#>  +      -2.3365 (normalized) V24
#>  +       2.5821 (normalized) V25
#>  +       2.1557 (normalized) V26
#>  +      -0.5104 (normalized) V27
#>  +      -0.6061 (normalized) V28
#>  +       1.1574 (normalized) V29
#>  +       0.0936 (normalized) V3
#>  +      -1.1624 (normalized) V30
#>  +       1.9395 (normalized) V31
#>  +      -0.6458 (normalized) V32
#>  +       0.0212 (normalized) V33
#>  +       0.5935 (normalized) V34
#>  +       0.6086 (normalized) V35
#>  +       3.4276 (normalized) V36
#>  +       2.1409 (normalized) V37
#>  +      -1.5694 (normalized) V38
#>  +      -1.4273 (normalized) V39
#>  +      -2.3192 (normalized) V4
#>  +       1.7753 (normalized) V40
#>  +      -0.9458 (normalized) V41
#>  +       1.1036 (normalized) V42
#>  +      -0.21   (normalized) V43
#>  +      -2.9666 (normalized) V44
#>  +      -3.606  (normalized) V45
#>  +      -2.9208 (normalized) V46
#>  +      -0.5605 (normalized) V47
#>  +      -0.696  (normalized) V48
#>  +      -1.5299 (normalized) V49
#>  +      -1.7726 (normalized) V5
#>  +       5.0382 (normalized) V50
#>  +      -0.9428 (normalized) V51
#>  +      -1.2538 (normalized) V52
#>  +      -0.3811 (normalized) V53
#>  +      -0.5717 (normalized) V54
#>  +       0.9272 (normalized) V55
#>  +       0.1163 (normalized) V56
#>  +       0.9096 (normalized) V57
#>  +      -1.4515 (normalized) V58
#>  +      -2.6182 (normalized) V59
#>  +      -0.11   (normalized) V6
#>  +       0.5502 (normalized) V60
#>  +       1.1296 (normalized) V7
#>  +       0.4029 (normalized) V8
#>  +      -2.1865 (normalized) V9
#>  +       2.02  


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

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