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', predict_raw = 'FALSE'

# 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.1468607 -0.7146387 -1.315224 -0.8646139 -0.7105757 0.08960983 0.6513622
#>            V16       V17       V18        V19         V2        V20        V21
#> [1,] 0.7358624 0.4727125 0.2499027 -0.1084058 -0.2123314 -0.5530866 -0.6367902
#>             V22       V23       V24       V25        V26       V27        V28
#> [1,] -0.5923754 -0.165028 0.2491901 0.4085529 0.06280729 0.1101356 -0.2737084
#>            V29         V3        V30       V31        V32      V33       V34
#> [1,] -0.288805 -0.1481141 -0.1339523 0.6004006 0.05241929 0.139784 0.4858883
#>            V35      V36      V37        V38        V39         V4       V40
#> [1,] 0.6408274 1.114973 0.768279 0.01948069 -0.4623764 -0.3057675 0.2639739
#>              V41        V42        V43       V44       V45       V46        V47
#> [1,] -0.04268381 -0.8253183 -0.9570213 -1.008127 -1.419595 -1.305608 -0.8364215
#>             V48        V49         V5         V50         V51         V52
#> [1,] -0.8059696 -0.4450627 -0.3363557 -0.03378202 -0.09127184 -0.07173035
#>              V53         V54          V55         V56        V57         V58
#> [1,] -0.04143389 -0.04044899 -0.004952529 -0.02506386 0.01874573 -0.04183436
#>              V59         V6         V60        V7          V8        V9
#> [1,] -0.03473613 0.02028481 0.006444802 0.2261218 -0.09005047 -0.553698
#>          Bias
#> [1,] 1.081042
#> 
#> $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.3188406