Skip to contents

Sparse Linear Discriminant Analysis for classification. Calls sparseLDA::sda() from sparseLDA.

Custom mlr3 parameters

  • Q is set internally to min(n_features, n_classes - 1) when not supplied.

  • stop is not exposed because it depends on the task.

Dictionary

This Learner can be instantiated via lrn():

lrn("classif.sparseLDA")

Meta Information

  • Task type: “classif”

  • Predict Types: “response”, “prob”

  • Feature Types: “integer”, “numeric”

  • Required Packages: mlr3, sparseLDA, MASS, elasticnet

Parameters

IdTypeDefaultLevelsRange
lambdanumeric1e-06\([0, \infty)\)
maxIteinteger100\([0, \infty)\)
tolnumeric1e-06\([0, \infty)\)
tracelogicalFALSETRUE, 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

Author

awinterstetter

Super classes

mlr3::Learner -> mlr3::LearnerClassif -> LearnerClassifSparseLDA

Methods

Inherited methods


Method new()

Creates a new instance of this R6 class.


Method clone()

The objects of this class are cloneable with this method.

Usage

LearnerClassifSparseLDA$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

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