Runs a recursive feature elimination with a mlr3learners::LearnerClassifSVM.
The SVM must be configured with type = "C-classification"
and kernel = "linear"
.
Source
Guyon I, Weston J, Barnhill S, Vapnik V (2002). “Gene Selection for Cancer Classification using Support Vector Machines.” Machine Learning, 46(1), 389--422. ISSN 1573-0565, doi:10.1023/A:1012487302797 .
Examples
clbk("mlr3fselect.svm_rfe")
#> <CallbackFSelect:mlr3fselect.svm_rfe>: SVM-RFE Callback
#> * Active Stages: on_optimization_begin
library(mlr3learners)
# Create instance with classification svm with linear kernel
instance = fsi(
task = tsk("sonar"),
learner = lrn("classif.svm", type = "C-classification", kernel = "linear"),
resampling = rsmp("cv", folds = 3),
measures = msr("classif.ce"),
terminator = trm("none"),
callbacks = clbk("mlr3fselect.svm_rfe"),
store_models = TRUE
)
fselector = fs("rfe", feature_number = 5, n_features = 10)
# Run recursive feature elimination on the Sonar data set
fselector$optimize(instance)
#> V1 V10 V11 V12 V13 V14 V15 V16 V17 V18 V19 V2 V20
#> 1: TRUE FALSE FALSE TRUE FALSE FALSE FALSE FALSE TRUE FALSE TRUE FALSE FALSE
#> V21 V22 V23 V24 V25 V26 V27 V28 V29 V3 V30 V31 V32
#> 1: FALSE FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE TRUE TRUE
#> V33 V34 V35 V36 V37 V38 V39 V4 V40 V41 V42 V43 V44
#> 1: FALSE FALSE FALSE FALSE TRUE FALSE FALSE FALSE TRUE FALSE FALSE FALSE FALSE
#> V45 V46 V47 V48 V49 V5 V50 V51 V52 V53 V54 V55 V56
#> 1: TRUE FALSE FALSE FALSE TRUE TRUE TRUE TRUE TRUE FALSE FALSE FALSE FALSE
#> V57 V58 V59 V6 V60 V7 V8 V9 features
#> 1: FALSE FALSE FALSE TRUE FALSE TRUE TRUE TRUE V1,V12,V17,V19,V23,V30,...
#> classif.ce
#> 1: 0.2355418