根据新数据预测后缺少条目

时间:2018-07-30 14:14:35

标签: r classification roc

我已经在一些带有标签的客户付款数据上训练了XGB模型,目的是将两类的未来付款行为作为2级因子进行预测。

XGB.prediction <- predict(object = XGB,
                          newdata = df.test,
                          type = "prob")

df.test是一个包含2534 obs的数据帧。 43个变量。

XBG.prediction因此,我希望是2534磅。 2个变量及其概率但是,只有1416 obs。

我试图确定NA值是否可能导致这种情况

> anyNA(df.test$Class)
   [1] FALSE

当尝试通过ROC评估我的模型时,这会产生问题。

> xgb.roc <- roc(response = df.test$Class,
               auc = TRUE,
               plot = TRUE,
               predictor = XGB.prediction[,"payer"])



 Error in roc.default(response = df.test$Class, auc = TRUE, plot = TRUE,  : 
      Response and predictor must be vectors of the same length.

模型训练参数如下

XGB <- train(

  Class ~ .,

  data = df.train,

  trControl = ctrl,

  method = "xgbTree",

  tuneGrid = grid.xgboost,

  importance = 'impurity',

  metric = "ROC")

0 个答案:

没有答案
相关问题