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.2212175 -0.7951864 -1.136699 -0.7813269 -0.1476735 0.1980257 0.177468
#>            V16       V17       V18        V19         V2        V20        V21
#> [1,] 0.3778547 0.6803556 0.5740521 -0.2280082 -0.1589607 -0.3401252 -0.3290399
#>             V22        V23         V24       V25       V26         V27
#> [1,] -0.6394002 -0.4461598 -0.06761733 0.4038318 0.2970109 -0.09639017
#>             V28         V29          V3         V30       V31         V32
#> [1,] -0.4891547 -0.09211374 -0.03131772 -0.02976731 0.8134151 -0.09914524
#>             V33      V34       V35       V36       V37         V38        V39
#> [1,] 0.06127838 0.878001 0.7502239 0.9349072 0.4291628 -0.08786183 -0.2931037
#>              V4       V40         V41        V42      V43        V44       V45
#> [1,] -0.4576373 0.2996169 -0.02560734 -0.7855456 -1.00349 -0.7843897 -1.285893
#>            V46        V47        V48        V49         V5         V50
#> [1,] -1.275619 -0.6937479 -0.5654674 -0.3959494 -0.2598212 -0.07450537
#>             V51         V52         V53         V54        V55         V56
#> [1,] -0.1172153 -0.08622472 -0.02955797 -0.05198325 0.02494318 0.003025125
#>            V57         V58         V59         V6        V60         V7
#> [1,] 0.0202132 -0.03601728 -0.03857392 0.06766972 -0.0370413 0.03074385
#>              V8         V9     Bias
#> [1,] -0.1495068 -0.6559827 1.005449
#> 
#> $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.2318841