mlr3proba
使用 R 的和mlr3pipelines
和包运行下面的代码以在预处理数据集上mlr3filters
实现rpart
算法并执行“变量重要性”,显示错误:
task <- tsk("iris")
learner <- lrn("classif.rpart")
learner <- po("encode") %>>% po("scale") %>>% po("learner", learner) # preprocessing
learner <- GraphLearner$new(learner) #applying learner on a graph in mlr3pipelines
filter <- flt("importance", learner = learner) #using filter for variable importance
filter$calculate(task)
#Error:
Error in learner$importance() : attempt to apply non-function
但是当我运行上面的代码时,没有预处理,它可以工作:
task <- tsk("iris")
learner <- lrn("classif.rpart")
filter <- flt("importance", learner = learner)
filter$calculate(task)
as.data.table(filter)
#Results:
feature score
1: Petal.Width 88.96940
2: Petal.Length 81.34496
3: Setal.Length 54.09606
4: Sepal.Width 36.01309
那么,有什么问题呢?