R caret train Error in evalSummaryFunction: cannnot compute class probabilities for regression -
> cv.ctrl <- traincontrol(method = "repeatedcv", repeats = 3, +                         summaryfunction = twoclasssummary, +                         classprobs = true) >  > set.seed(35) > glm.tune.1 <- train(y ~ bool_3, +                     data = train.batch, +                     method = "glm", +                     metric = "roc", +                     trcontrol = cv.ctrl) error in evalsummaryfunction(y, trcontrol, classlevels, metric, method) :    train()'s use of roc codes requires class probabilities. see classprobs option of traincontrol() in addition: warning message: in train.default(x, y, weights = w, ...) :   cannnot compute class probabilities regression    > str(train.batch) 'data.frame':   128046 obs. of  42 variables:  $ offer               : int  1194044 1194044 1194044 1194044 1194044 1194044 1194044 1194044 1194044 1194044 ...  $ avgprice            : num  2.68 2.68 2.68 2.68 2.68 ...  ...  $ bool_3              : int  0 0 0 0 0 0 0 1 0 0 ...  $ y                   : num  0 1 0 0 0 1 1 1 1 0 ...   since cv.ctrl has classprobs set true, not understand why error message appears.
can advise?
apparently error due fact y not factor.
following code works fine:
library(caret) library(mlbench) data(sonar)  ctrl <- traincontrol(method = "cv",                       summaryfunction = twoclasssummary,                       classprobs = true) set.seed(1) gbmtune <- train(class ~ ., data = sonar,                  method = "gbm",                  metric = "roc",                  verbose = false,                                      trcontrol = ctrl)   then doing:
sonar$class = as.numeric(sonar$class)   and same code throws error:
> gbmtune <- train(class ~ ., data = sonar, +                  method = "gbm", +                  metric = "roc", +                  verbose = false,                     +                  trcontrol = ctrl) error in evalsummaryfunction(y, trcontrol, classlevels, metric, method) :    train()'s use of roc codes requires class probabilities. see classprobs option of traincontrol() in addition: warning message: in train.default(x, y, weights = w, ...) :   cannnot compute class probabilities regression   but caret train documentation says:
y   numeric or factor vector containing outcome each sample.      
Comments
Post a Comment