makeModelMultiplexerParamSet
的文档名为ParamSets的mlr R包状态可以提供,以消除哪些参数流向哪个学习者的歧义,但文档中没有包含如何做到这一点的示例。我已经尝试了一些事情(比如下面显示的(,但我可以让makeModelMultiplexerParamSet
工作。如有任何帮助,我们将不胜感激。
base.learners = list(
makeLearner("classif.ksvm", predict.type = 'prob'),
makeLearner("classif.randomForest", predict.type = 'prob', ntree=500L),
makeLearner('classif.xgboost', predict.type = 'prob', nthread=2, nrounds=1000L)
)
lrn = makeModelMultiplexer(base.learners)
# learners
ps = list(
classif.randomForest = makeParamSet(makeIntegerParam("mtry", lower=1L, upper=100L)),
classif.ksvm = makeParamSet(makeNumericParam("C", lower = 0.01, upper = 0.1),
makeNumericParam("sigma", lower = 0.005, upper = 0.5, trafo = function(x) 2^x)),
classif.xgboost = makeParamSet(makeIntegerParam("max_depth", lower=1L, upper=100L),
makeNumericParam("eta", lower=0.05, upper=0.5),
makeNumericParam("gamma", lower=0, upper=1))
)
ps = makeModelMultiplexerParamSet(lrn, ps)
错误:
Error in FUN(X[[i]], ...): List args has element of wrong type list at position 1. Should be: ParamSet
Traceback:
1. makeModelMultiplexerParamSet(lrn, ps)
2. checkListElementClass(args, "ParamSet")
3. lapply(seq_along(xs), function(i) {
. x = xs[[i]]
. if (!(is(x, cl)))
. stop("List ", s, " has element of wrong type ", class(x)[1L],
. " at position ", i, ". Should be: ", cl)
. })
4. FUN(X[[i]], ...)
5. stop("List ", s, " has element of wrong type ", class(x)[1L],
. " at position ", i, ". Should be: ", cl)
这种方法解决了问题:https://www.rdocumentation.org/packages/mlr/versions/2.17.1/topics/makeModelMultiplexer
使用makeModelMultiplexerParamSet((包装makeParams;例如ps = makeModelMultiplexerParamSet(lrn, classif.ksvm = makeParamSet( makeNumericParam("sigma", lower = -10, upper = 10, trafo = function(x) 2^x) ), classif.randomForest = makeParamSet( makeIntegerParam("ntree", lower = 1L, upper = 500L) ) )