LiblineaR Classification Learner
mlr_learners_classif.liblinear.Rd
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 Singer5
- L1-regularized L2-loss support vector classification6
- L1-regularized logistic regression7
- 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.
Meta Information
Task type: “classif”
Predict Types: “response”, “prob”
Feature Types: “numeric”
Required Packages: mlr3, mlr3extralearners, LiblineaR
Parameters
Id | Type | Default | Levels | Range |
type | integer | 0 | \([0, 7]\) | |
cost | numeric | 1 | \([0, \infty)\) | |
epsilon | numeric | - | \([0, \infty)\) | |
bias | numeric | 1 | \((-\infty, \infty)\) | |
cross | integer | 0 | \([0, \infty)\) | |
verbose | logical | FALSE | TRUE, FALSE | - |
wi | untyped | NULL | - | |
findC | logical | FALSE | TRUE, FALSE | - |
useInitC | logical | TRUE | TRUE, 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
as.data.table(mlr_learners)
for a table of available Learners in the running session (depending on the loaded packages).Chapter in the mlr3book: https://mlr3book.mlr-org.com/basics.html#learners
mlr3learners for a selection of recommended learners.
mlr3cluster for unsupervised clustering learners.
mlr3pipelines to combine learners with pre- and postprocessing steps.
mlr3tuning for tuning of hyperparameters, mlr3tuningspaces for established default tuning spaces.
Super classes
mlr3::Learner
-> mlr3::LearnerClassif
-> LearnerClassifLiblineaR
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.1675441 -1.011929 -1.307005 -0.9830977 -0.7002241 0.1033993 0.3970572
#> V16 V17 V18 V19 V2 V20 V21
#> [1,] 0.739781 0.3611696 0.0366113 -0.3233472 -0.2117794 -0.1639752 -0.301485
#> V22 V23 V24 V25 V26 V27
#> [1,] -0.3369172 -0.3945042 -0.09882614 0.6207741 0.3847505 -0.1136221
#> V28 V29 V3 V30 V31 V32
#> [1,] -0.4125949 -0.03496506 -0.2545783 0.08171528 0.9816543 0.2009526
#> V33 V34 V35 V36 V37 V38 V39
#> [1,] 0.09074408 0.429448 0.367367 0.8128293 0.6064429 -0.1204484 -0.04777865
#> V4 V40 V41 V42 V43 V44 V45
#> [1,] -0.5762917 0.5009287 -0.2782325 -0.6843372 -0.9817817 -1.111098 -1.336528
#> V46 V47 V48 V49 V5 V50
#> [1,] -0.9839507 -0.6299716 -0.8021713 -0.5643749 -0.4719461 -0.08125249
#> V51 V52 V53 V54 V55 V56
#> [1,] -0.07975648 -0.0888186 -0.03099822 -0.05809959 0.002103619 -0.008625561
#> V57 V58 V59 V6 V60 V7
#> [1,] -0.0136484 -0.05386995 -0.05205573 -0.09160009 -0.01471076 -0.00663481
#> V8 V9 Bias
#> [1,] -0.007521194 -0.8482334 0.8066413
#>
#> $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.173913