R错误提升图表y变量必须是两级因子

时间:2018-03-17 18:45:47

标签: r logistic-regression curves

我一直试图从我的Logistic回归中提出一条升力曲线,但它似乎没有用。

关注我一直在尝试的代码

inTrain <- createDataPartition(y = Data$Response, p = .60, list = FALSE)
training <- Data[inTrain,]
testing <- Data[-inTrain,]
fullmod = glm(Response ~ page_views_90d+win_visits+osx_visits+mc_1+mc_2+mc_3+mc_4+mc_5+mc_6+store_page+orders+orderlines+bookings+purchase, family=binomial(logit),data=training )
lift.chart(c("fullmod"), data=training, targLevel="Yes",
           trueResp=0.01, type="incremental", sub="Test")

我一直收到以下错误,

Error in lift.chart(c("fullmodWorks"), data = DataVal, targLevel = 1,  : 
  The y variable must be a two-level factor.

1 个答案:

答案 0 :(得分:0)

在创建训练/测试分区之前尝试一下。

Data$Response <- as.factor(Data$Response)