我在数据集上运行4个分类器并比较它们的性能。当我运行以下代码时,我收到一些奇怪的错误:
library(mlbench)
library(mlr)
maxx_IL10 = c(3199, 2997, 2690, 2482, 2891, 2310, 3180, 3050, 3115, 3052, 3071, 3068, 2611, 2723, 2903, 2969)
auc_INTERLEUKIN_12P70 = c(14809, 1384.5, 760, 10922.5, 3010, 14564, 26496, 1229, 2509, 1474.5, 20697.5, 1854.5, 17352, 1457, 227, 31507.5)
maxx_TNFA = c(3066, 2658, 2697, 3175, 2904, 2260, 2714, 3056, 3155, 3030, 3125, 2456, 3017, 2860, 1704, 3167)
fold_IL4 = c(16.02685, 0, 4.616438, 53.44898, 0, 0, 68.85714, 5.833333, 25.9, 0, 21.87629, 20.57895, 20.18792, 4.394737, 7.723404, 56.6383)
maxx_CD19 = c(3045.5, 3045.5, 3045.5, 3045.5, 2667, 1865, 3126, 2432, 3244, 3218, 2415, 3077, 3223, 2549, 3016, 3244)
auc_IL4 = c(18315.5, 0, 1348, 31112, 0, 0, 19182.5, 525, 3201.5, 0, 12976, 782, 19195.5, 835, 544.5, 26658)
Class = c("B", "A", "A", "A", "A", "A", "B", "A", "B", "B", "B", "A", "B", "A", "A", "B")
df = data.frame(maxx_IL10, auc_INTERLEUKIN_12P70, maxx_TNFA, fold_IL4, maxx_CD19, auc_IL4, Class)
Class.task = makeClassifTask( data = df, target = "Class", positive ="B")
fv = generateFilterValuesData(Class.task, method = "mrmr")
plotFilterValues(fv)
filtered.task = filterFeatures(Class.task, fval = fv, threshold = -.2)
n = getTaskSize(filtered.task)
train.set = sample(n, size = round(2/3 * n))
test.set = setdiff(seq_len(n), train.set)
lrn1 = makeLearner("classif.lda", predict.type = "prob")
mod1 = train(lrn1, filtered.task, subset = train.set)
pred1 = predict(mod1, task = filtered.task, subset = test.set)
lrn2 = makeLearner("classif.ksvm", predict.type = "prob")
mod2 = train(lrn2, filtered.task, subset = train.set)
pred2 = predict(mod2, task = filtered.task, subset = test.set)
lrn3 = makeLearner("classif.randomForest", predict.type = "prob")
mod3 = train(lrn3, Class.task, subset = train.set)
pred3 = predict(mod3, task = Class.task, subset = test.set)
lrn5 = makeLearner("classif.xgboost", predict.type = "prob")
mod5 = train(lrn5, Class.task, subset = train.set)
pred5 = predict(mod5, task = Class.task, subset = test.set)
### Tune wrapper for ksvm
rdesc.inner = makeResampleDesc("Holdout")
ms = list(auc, mmce)
ps = makeParamSet(
makeDiscreteParam("C", 2^(-1:1))
)
ctrl = makeTuneControlGrid()
lrn2 = makeTuneWrapper(lrn2, rdesc.inner,ms, ps, ctrl, show.info = FALSE)
lrns = list(lrn1, lrn2,lrn3,lrn5)
rdesc.outer = makeResampleDesc("CV", iters = 5)
bmr = benchmark(lrns, tasks = filtered.task, resampling = rdesc.outer, measures = ms, show.info = FALSE)
bmr
我收到的错误是:
lrn2 = makeTuneWrapper(lrn2,rdesc.inner,ms,ps,ctrl,show.info = FALSE) makeTuneWrapper出错(lrn2,rdesc.inner,ms,ps,ctrl,show.info = FALSE): 关于'措施'的断言失败:可能只包含以下类型:措施。 lrns = list(lrn1,lrn2,lrn3,lrn5) rdesc.outer = makeResampleDesc(“CV”,iters = 5)
bmr = benchmark(lrns,tasks = filtered.task,resampling = rdesc.outer,measures = ms,show.info = FALSE) FUN错误(X [[i]],...): 列表测量在位置1具有错误类型功能的元素。应该是:测量 基础代谢率 错误:未找到对象'bmr'
关于我做错的任何想法?谢谢!!