Skip to contents

L2 regularized support vector classification. Calls LiblineaR::LiblineaR() from LiblineaR.

Details

Type of SVC depends on type argument:

  • 0 – L2-regularized logistic regression (primal)

  • 1 - L2-regularized L2-loss support vector classification (dual)

  • 3 - L2-regularized L1-loss support vector classification (dual)

  • 2 – L2-regularized L2-loss support vector classification (primal)

  • 4 – Support vector classification by Crammer and Singer

  • 5 - L1-regularized L2-loss support vector classification

  • 6 - L1-regularized logistic regression

  • 7 - L2-regularized logistic regression (dual)

If number of records > number of features, type = 2 is faster than type = 1 (Hsu et al. 2003).

Note that probabilistic predictions are only available for types 0, 6, and 7. The default epsilon value depends on the type parameter, see LiblineaR::LiblineaR.

Dictionary

This Learner can be instantiated via lrn():

lrn("classif.liblinear")

Meta Information

  • Task type: “classif”

  • Predict Types: “response”, “prob”

  • Feature Types: “numeric”

  • Required Packages: mlr3, mlr3extralearners, LiblineaR

Parameters

IdTypeDefaultLevelsRange
typeinteger0\([0, 7]\)
costnumeric1\([0, \infty)\)
epsilonnumeric-\([0, \infty)\)
biasnumeric1\((-\infty, \infty)\)
crossinteger0\([0, \infty)\)
verboselogicalFALSETRUE, FALSE-
wiuntypedNULL-
findClogicalFALSETRUE, FALSE-
useInitClogicalTRUETRUE, FALSE-

References

Fan, Rong-En, Chang, Kai-Wei, Hsieh, Cho-Jui, Wang, Xiang-Rui, Lin, Chih-Jen (2008). “LIBLINEAR: A library for large linear classification.” the Journal of machine Learning research, 9, 1871–1874.

See also

Author

be-marc

Super classes

mlr3::Learner -> mlr3::LearnerClassif -> LearnerClassifLiblineaR

Methods

Inherited methods


Method new()

Creates a new instance of this R6 class.


Method clone()

The objects of this class are cloneable with this method.

Usage

LearnerClassifLiblineaR$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

# Define the Learner
learner = lrn("classif.liblinear")
print(learner)
#> 
#> ── <LearnerClassifLiblineaR> (classif.liblinear): Support Vector Machine ───────
#> • Model: -
#> • Parameters: list()
#> • Packages: mlr3, mlr3extralearners, and LiblineaR
#> • Predict Types: [response] and prob
#> • Feature Types: numeric
#> • Encapsulation: none (fallback: -)
#> • Properties: multiclass and twoclass
#> • Other settings: use_weights = 'error'

# 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(learner$model)
#> $TypeDetail
#> [1] "L2-regularized logistic regression primal (L2R_LR)"
#> 
#> $Type
#> [1] 0
#> 
#> $W
#>              V1        V10       V11      V12        V13        V14       V15
#> [1,] -0.1130535 -0.8231548 -1.349811 -1.26129 -0.7266066 -0.1280229 0.1895006
#>            V16      V17       V18        V19         V2        V20       V21
#> [1,] 0.4591842 0.548823 0.3935641 -0.2162527 -0.2341263 -0.6829925 -0.509967
#>             V22        V23         V24       V25      V26       V27       V28
#> [1,] -0.2216838 0.04618201 -0.05144624 0.1750428 0.473645 0.1693273 -0.375293
#>             V29         V3        V30       V31       V32       V33       V34
#> [1,] -0.4268771 -0.1647236 -0.3897179 0.9283025 0.2627057 0.5010834 0.5016236
#>            V35       V36       V37         V38       V39         V4       V40
#> [1,] 0.2867206 0.9290123 0.7532899 -0.06095151 -0.465163 -0.3736881 0.5148237
#>              V41        V42        V43       V44       V45        V46
#> [1,] 0.004669666 -0.1109462 -0.5553822 -1.009339 -1.501543 -0.7749714
#>             V47        V48        V49         V5          V50         V51
#> [1,] -0.4819049 -0.5301295 -0.3005167 -0.2089915 -0.006388392 -0.06775065
#>              V52         V53         V54         V55         V56         V57
#> [1,] -0.09502396 -0.01837985 -0.03918567 -0.02219057 -0.03894059 -0.01086143
#>              V58         V59          V6          V60        V7         V8
#> [1,] -0.02913887 -0.03767529 -0.07658007 -0.006934783 0.1396196 -0.0952947
#>              V9    Bias
#> [1,] -0.8736999 0.71095
#> 
#> $Bias
#> [1] 1
#> 
#> $ClassNames
#> [1] R M
#> Levels: M R
#> 
#> $NbClass
#> [1] 2
#> 
#> attr(,"class")
#> [1] "LiblineaR"


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

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