R多类roc错误:响应和预测变量必须是相同长度的向量

时间:2018-09-19 16:30:19

标签: r statistics prediction roc

我正在为具有4类的响应变量构建roc曲线。我计算了预测变量,但是当将其输入 pROC 包的函数multiclass.roc时,会出现以下错误:

Error in roc.default(response, predictor, levels = X, percent = percent,  : 
  Response and predictor must be vectors of the same length.

这是我的代码:

md2 <- glmnet(as.matrix(train), train_label, lambda = cv2$lambda.min, family = 'multinomial', alpha = cv2$alpha)
roc_sexage_elnet <- multiclass.roc(test_label, as.matrix(predict(md2, as.matrix(test), type = "response")))

我尝试检查各种示例,但我对此一无所知。

0 个答案:

没有答案