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/chapters/chapter2/data_and_basic_modeling.html#sec-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()
LearnerClassifLiblineaR$new()
Creates a new instance of this R6 class.
Usage
LearnerClassifLiblineaR$new()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.2554701 -0.513421 -0.9856333 -1.020212 -0.6548117 0.08137784 0.723414
#> V16 V17 V18 V19 V2 V20 V21
#> [1,] 0.8734893 0.7424871 0.07357369 -0.1402192 -0.2129134 -0.4399208 -0.5908435
#> V22 V23 V24 V25 V26 V27 V28
#> [1,] -0.7326877 -0.4628399 -0.2117532 0.1290413 0.194853 0.4347117 0.07867701
#> V29 V3 V30 V31 V32 V33
#> [1,] -0.009056155 -0.1443291 -0.08522314 0.6031817 0.06735788 0.2116136
#> V34 V35 V36 V37 V38 V39 V4
#> [1,] 0.6697625 0.381772 0.8761647 1.087279 -0.05560357 -0.4404807 -0.5097513
#> V40 V41 V42 V43 V44 V45 V46
#> [1,] 0.2203695 -0.04479037 -0.5843105 -1.309223 -1.153215 -1.205715 -0.9630928
#> V47 V48 V49 V5 V50 V51
#> [1,] -0.4045224 -0.4335707 -0.3423262 -0.5825174 -0.04883567 -0.08339089
#> V52 V53 V54 V55 V56 V57
#> [1,] -0.08081238 -0.03948982 -0.03374749 0.02953892 -0.01424665 0.02757073
#> V58 V59 V6 V60 V7 V8
#> [1,] -0.02698713 -0.03876812 -0.2127401 -0.03214824 0.1249896 -0.05689248
#> V9 Bias
#> [1,] -0.6310529 0.8600388
#>
#> $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.3043478