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       V15
#> [1,] -0.1484029 -1.106509 -1.412191 -1.428732 -0.7680794 0.3154968 0.5372189
#>            V16       V17        V18        V19         V2        V20        V21
#> [1,] 0.6262558 0.2472471 0.00472795 -0.5083168 -0.2221557 -0.5381943 -0.4143965
#>             V22        V23      V24       V25       V26      V27         V28
#> [1,] -0.3692429 0.01576907 0.230382 0.1744066 0.3047006 0.232987 -0.08079872
#>             V29         V3        V30       V31        V32         V33
#> [1,] -0.2270076 -0.2428424 -0.2567318 0.6093068 -0.2137433 -0.01866983
#>            V34       V35      V36       V37         V38        V39         V4
#> [1,] 0.4209204 0.8243508 1.153594 0.4723238 -0.08697219 -0.2344825 -0.3459638
#>           V40        V41        V42        V43        V44       V45        V46
#> [1,] 0.588519 0.09473196 -0.7381283 -0.7055577 -0.7126205 -1.060798 -0.8425847
#>             V47       V48        V49        V5         V50        V51
#> [1,] -0.7722086 -0.756961 -0.4360016 -0.376015 -0.02983833 -0.1024928
#>             V52         V53         V54        V55         V56          V57
#> [1,] -0.1150138 -0.02858047 -0.04086031 0.01892755 -0.02886863 -0.001377664
#>              V58         V59          V6         V60        V7          V8
#> [1,] -0.03709844 -0.01135711 -0.06539743 0.004478439 0.1346446 0.008586892
#>             V9      Bias
#> [1,] -1.098905 0.9995733
#> 
#> $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