我想使用包“partykit”通过 ctree() 和 cforest() 构建分类树和森林。
由于我的数据集包含 50000 行和 30 列,我想将 minsplit 设置为 150,将 minbucket 设置为 50。
不幸的是,当我输入我的代码时
xplr=ctree_control(mincriterion = 0.999, minsplit=150, minbucket=50)
set.seed(123)
cit999=ctree(as.factor(order) ~ startHour, data=transact_train, controls=xplr)
我收到以下错误消息:
Error in ctree_control(...) :
unused argument (controls = list(teststat = "quad", testtype = "Bonferroni", mincriterion = -0.00100050033358353, minsplit = 150, minbucket = 50, minprob = 0.01, stump = FALSE, mtry = Inf, maxdepth = Inf, multiway = FALSE, splittry = 2, maxsurrogate = 0, majority = FALSE, applyfun = function (X, FUN, ...)
{
FUN <- match.fun(FUN)
if (!is.vector(X) || is.object(X)) X <- as.list(X)
.Internal(lapply(X, FUN))
}))
谁能告诉我为什么会这样?
最佳答案
这是因为您指定了 controls
而不是 control
。
require(partykit)
data(HuntingSpiders) # example data from partykit
xplr=ctree_control(mincriterion = 0.999, minsplit=150, minbucket=50)
set.seed(123)
arct.lute <- as.factor(HuntingSpiders$arct.lute)
cit999=ctree(formula=arct.lute ~ ., data=HuntingSpiders, control=xplr)
cit999
Model formula:
arct.lute ~ pard.lugu + zora.spin + pard.nigr + pard.pull + aulo.albi +
troc.terr + alop.cune + pard.mont + alop.acce + alop.fabr +
arct.peri + water + sand + moss + reft + twigs + herbs
Fitted party:
[1] root: 0.35714285714 (n = 28, err = 14.428571429)
Number of inner nodes: 0
Number of terminal nodes: 1
>
关于R 包 'partykit' ctree_control 中未使用的参数,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/37703154/