我尝试在MLR中使用MSE来分割我的决策树。以下是我的代码
library(mlr)cl = "classif.rpart"getParamSet(cl)learner = makeLearner(cl = cl , predict.type = "prob" #, predict.type = "response" , par.vals = list(split="mse") , fix.factors.prediction = TRUE)
这导致了以下错误
Error in setHyperPars2.Learner(learner, insert(par.vals, args)) : classif.rpart: Setting parameter split without available description object!Did you mean one of these hyperparameters instead: minsplit cp xvalYou can switch off this check by using configureMlr!
我知道如何在rpart
中操作,但对MLR
却一无所知
回答:
split
参数在rpart(..., parms = list(split = "mse"))
中作为列表传递。因此,它可以在mlr中这样设置:
library(mlr)cl = "classif.rpart"learner = makeLearner(cl = cl, predict.type = "prob", par.vals = list(parms = list(split="mse")), fix.factors.prediction = TRUE)m = train(learner, iris.task)
在结果中我们可以看到它被正确传递了
m$learner.model$call# rpart::rpart(formula = f, data = d, parms = list(split = "mse"), xval = 0L)