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.1377876 -0.7047766 -1.098179 -1.019706 -0.6832497 -0.1094154 0.3619942
#> V16 V17 V18 V19 V2 V20 V21
#> [1,] 0.8110644 0.4207263 0.2028633 -0.09790151 -0.3048851 -0.3349879 -0.2712929
#> V22 V23 V24 V25 V26 V27 V28
#> [1,] -0.235157 -0.5588025 -0.4516719 0.3168683 0.2255533 0.2497448 -0.2704269
#> V29 V3 V30 V31 V32 V33 V34
#> [1,] -0.2232352 -0.3532993 -0.1118702 0.7601825 -0.07415511 0.1857099 0.4791852
#> V35 V36 V37 V38 V39 V4 V40
#> [1,] 0.4749974 0.8634666 0.7556131 0.1194989 -0.07440937 -0.4771586 0.5664937
#> V41 V42 V43 V44 V45 V46
#> [1,] -0.02738167 -0.8903491 -0.8813797 -0.7724972 -1.117117 -0.942956
#> V47 V48 V49 V5 V50 V51
#> [1,] -0.5630921 -0.6925133 -0.436498 -0.4197876 -0.01936831 -0.09675127
#> V52 V53 V54 V55 V56 V57
#> [1,] -0.1033983 -0.04467036 -0.06850629 0.004217908 -0.02307086 0.01515884
#> V58 V59 V6 V60 V7 V8
#> [1,] -0.05035951 -0.03766793 -0.2411818 -0.001999319 0.130377 -0.351562
#> V9 Bias
#> [1,] -0.8189618 0.9856689
#>
#> $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.2608696