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.3749 (normalized) V1
#>  +      -0.0353 (normalized) V10
#>  +      -2.4726 (normalized) V11
#>  +      -3.0281 (normalized) V12
#>  +      -0.2391 (normalized) V13
#>  +       1.8267 (normalized) V14
#>  +       1.0585 (normalized) V15
#>  +      -0.1364 (normalized) V16
#>  +       0.5481 (normalized) V17
#>  +       1.2435 (normalized) V18
#>  +      -0.6708 (normalized) V19
#>  +      -0.3966 (normalized) V2
#>  +      -0.4796 (normalized) V20
#>  +       0.0809 (normalized) V21
#>  +      -0.8816 (normalized) V22
#>  +      -1.5598 (normalized) V23
#>  +      -0.7134 (normalized) V24
#>  +      -0.2671 (normalized) V25
#>  +       1.1503 (normalized) V26
#>  +       0.9717 (normalized) V27
#>  +      -1.5217 (normalized) V28
#>  +       0.4245 (normalized) V29
#>  +       0.4409 (normalized) V3
#>  +      -2.5413 (normalized) V30
#>  +       3.0694 (normalized) V31
#>  +       0.3071 (normalized) V32
#>  +      -1.1687 (normalized) V33
#>  +       0.088  (normalized) V34
#>  +       0.32   (normalized) V35
#>  +       1.9799 (normalized) V36
#>  +       1.0085 (normalized) V37
#>  +      -2.1819 (normalized) V38
#>  +      -1.4745 (normalized) V39
#>  +      -2.6017 (normalized) V4
#>  +       3.3279 (normalized) V40
#>  +       0.0356 (normalized) V41
#>  +      -0.5185 (normalized) V42
#>  +       0.0783 (normalized) V43
#>  +      -0.4834 (normalized) V44
#>  +      -2.5823 (normalized) V45
#>  +       0.2793 (normalized) V46
#>  +      -0.0509 (normalized) V47
#>  +      -1.7598 (normalized) V48
#>  +      -2.069  (normalized) V49
#>  +      -1.6261 (normalized) V5
#>  +       2.7246 (normalized) V50
#>  +      -2.2303 (normalized) V51
#>  +      -4.0937 (normalized) V52
#>  +      -0.7006 (normalized) V53
#>  +       0.2595 (normalized) V54
#>  +       1.4555 (normalized) V55
#>  +       0.0828 (normalized) V56
#>  +       0.13   (normalized) V57
#>  +      -1.3913 (normalized) V58
#>  +      -0.8182 (normalized) V59
#>  +      -0.4869 (normalized) V6
#>  +       1.0682 (normalized) V60
#>  +       1.7649 (normalized) V7
#>  +       0.0074 (normalized) V8
#>  +      -0.745  (normalized) V9
#>  +       3.71  


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

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