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 = mlr3::lrn("classif.liblinear")
print(learner)
#> <LearnerClassifLiblineaR:classif.liblinear>: Support Vector Machine
#> * Model: -
#> * Parameters: list()
#> * Packages: mlr3, mlr3extralearners, LiblineaR
#> * Predict Types:  [response], prob
#> * Feature Types: numeric
#> * Properties: multiclass, 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)
#> $TypeDetail
#> [1] "L2-regularized logistic regression primal (L2R_LR)"
#> 
#> $Type
#> [1] 0
#> 
#> $W
#>              V1        V10       V11        V12        V13         V14
#> [1,] -0.1418194 -0.7186022 -1.165349 -0.9642913 -0.8215547 -0.06194584
#>            V15       V16       V17         V18        V19         V2        V20
#> [1,] 0.5740965 0.5709226 0.5156379 0.003754762 -0.4427967 -0.1436171 -0.5908896
#>             V21        V22       V23       V24       V25        V26        V27
#> [1,] -0.6197999 -0.3167382 0.1852445 0.1544307 0.1764915 0.06509578 -0.1482797
#>             V28        V29          V3       V30       V31        V32
#> [1,] -0.2558497 -0.1305982 -0.09357295 0.4022394 0.6666322 -0.2077464
#>             V33       V34       V35       V36       V37       V38        V39
#> [1,] 0.02334119 0.4204697 0.5351451 0.9093566 0.7963585 0.2993114 -0.2203712
#>              V4       V40        V41        V42       V43       V44       V45
#> [1,] -0.4575288 0.2675753 -0.2764925 -0.6093886 -1.005413 -1.214619 -1.155607
#>             V46        V47        V48        V49        V5       V50
#> [1,] -0.8422541 -0.5320645 -0.5834187 -0.3467988 -0.375859 0.0137965
#>              V51         V52        V53         V54         V55        V56
#> [1,] -0.04714537 -0.07981345 -0.0239706 -0.03927172 0.001883097 0.00109768
#>            V57         V58         V59          V6          V60         V7
#> [1,] 0.0291474 -0.03834187 -0.03082046 -0.07932244 -0.005239954 0.08068083
#>              V8         V9      Bias
#> [1,] 0.01141992 -0.6784165 0.7767755
#> 
#> $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.2753623