我的任务是对回归任务进行分层,数据看起来像
f1,f2,f3,... m1,m2...,p1,p2,p3...
其中 f_i 是数字,其他列是因子和整数。
现在我定义了一个自定义度量 m1,运行以下命令后
measures1 = list(m1, medae)
measures2 = lapply(measures1, setAggregation, train.mean)
measures = c(measures1, measures2)
# rdesc = makeResampleDesc("CV", iters = 3, predict = "both", stratify.cols = "Iodine" ) #Default is 2/3, both=train&test
rdesc = makeResampleDesc("CV", iters = 3, predict = "both" ) #Default is 2/3
我得到错误说
[Resample] cross-validation iter: 1
Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) :
contrasts can be applied only to factors with 2 or more levels
当我将输入数据帧子集以仅包含数值数据时,没有这样的错误,实际上只有数值数据对预测有用,但我需要其他列在训练测试拆分中分层。有谁知道出了什么问题?