LiblineaR Classification Learner
Source:R/learner_LiblineaR_classif_liblinear.R
mlr_learners_classif.liblinear.RdL2 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
Methods
Inherited methods
mlr3::Learner$base_learner()mlr3::Learner$configure()mlr3::Learner$encapsulate()mlr3::Learner$format()mlr3::Learner$help()mlr3::Learner$predict()mlr3::Learner$predict_newdata()mlr3::Learner$print()mlr3::Learner$reset()mlr3::Learner$selected_features()mlr3::Learner$train()mlr3::LearnerClassif$predict_newdata_fast()
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
#> [1,] -0.2226696 -0.9976155 -1.085639 -0.9572193 -0.8158456 -0.009015576
#> V15 V16 V17 V18 V19 V2 V20
#> [1,] 0.3292312 0.7716018 0.8367208 0.6803559 -0.3194628 -0.2969424 -0.5092971
#> V21 V22 V23 V24 V25 V26 V27
#> [1,] -0.7266023 -0.6858248 -0.3386212 0.05685829 0.6960784 0.2416647 -0.2461134
#> V28 V29 V3 V30 V31 V32 V33
#> [1,] -0.2257746 -0.1473431 -0.2459362 0.1177568 1.024319 0.2984788 -0.005435985
#> V34 V35 V36 V37 V38 V39 V4
#> [1,] 0.1053718 0.410312 1.179976 0.7479645 -0.2794477 -0.3271733 -0.5797172
#> V40 V41 V42 V43 V44 V45 V46
#> [1,] 0.5749453 -0.3043423 -0.7016611 -1.053081 -1.098847 -1.336921 -0.8372005
#> V47 V48 V49 V5 V50 V51
#> [1,] -0.3921818 -0.4517884 -0.3049442 -0.5741055 3.867119e-05 -0.0623367
#> V52 V53 V54 V55 V56 V57
#> [1,] -0.09609704 -0.02640582 -0.05199666 -0.008407454 -0.02574697 0.00953249
#> V58 V59 V6 V60 V7 V8
#> [1,] -0.05146448 -0.06275012 -0.0833413 -0.02680819 0.158311 0.1786658
#> V9 Bias
#> [1,] -0.6334295 0.5693979
#>
#> $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.2898551