Sparse Discriminant Analysis
Source:R/learner_sparseLDA_classif_sparseLDA.R
mlr_learners_classif.sparseLDA.RdSparse Linear Discriminant Analysis for classification.
Calls sparseLDA::sda() from sparseLDA.
Custom mlr3 parameters
Qis set internally tomin(n_features, n_classes - 1)when not supplied.stopis not exposed because it depends on the task.
Meta Information
Task type: “classif”
Predict Types: “response”, “prob”
Feature Types: “integer”, “numeric”
Required Packages: mlr3, sparseLDA, MASS, elasticnet
Parameters
| Id | Type | Default | Levels | Range |
| lambda | numeric | 1e-06 | \([0, \infty)\) | |
| maxIte | integer | 100 | \([0, \infty)\) | |
| tol | numeric | 1e-06 | \([0, \infty)\) | |
| trace | logical | FALSE | TRUE, FALSE | - |
References
Clemmensen, Line, Hastie, Trevor, Witten, Daniela, Ersboll, Bjarne (2011). “Sparse discriminant analysis.” Journal of the American Statistical Association, 106(496), 1519–1531. doi:10.1198/jasa.2011.tm09728 .
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 -> LearnerClassifSparseLDA
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.sparseLDA")
print(learner)
#>
#> ── <LearnerClassifSparseLDA> (classif.sparseLDA): Sparse Discriminant Analysis ─
#> • Model: -
#> • Parameters: list()
#> • Packages: mlr3, sparseLDA, MASS, and elasticnet
#> • Predict Types: [response] and prob
#> • Feature Types: integer and 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)
#>
#> Call:
#> sda.default(x = x, y = y, Q = 1L)
#>
#> lambda = 1e-06
#> stop = 60 variables
#> classes = M, R
#>
#> Top 5 predictors (out of 60):
#> V6, V21, V45, V11, V41
# Make predictions for the test rows
predictions = learner$predict(task, row_ids = ids$test)
# Score the predictions
predictions$score()
#> classif.ce
#> 0.3768116