machine learning - unable to use Adaboost with R's caret package -
i'm using r's caret package implementing adaboost technique. i'm getting error while executing it.
> str(my_data) 'data.frame': 3885 obs. of 10 variables: $ date : factor w/ 12 levels "0","1","2","3",..: 3 3 3 3 3 3 3 3 3 3 ... $ japan : int 0 1 0 0 0 0 1 1 0 1 ... $ hongkong: int 0 1 0 1 0 0 0 1 1 1 ... $ china : int 1 0 1 1 1 1 0 1 1 0 ... $ india : int 0 0 0 1 0 0 1 1 0 1 ... $ germany : int 0 1 1 0 1 1 0 0 0 1 ... $ france : int 0 1 1 0 1 1 0 0 0 1 ... $ euro : int 0 1 1 0 1 1 0 0 0 1 ... $ london : int 0 1 1 0 1 1 0 0 0 1 ... $ dowjones: int 0 1 0 1 1 1 0 0 0 1 ... > train=my_data[1:3600,] #2015 > test=my_data[3601:3860,]
there no problem when i'm implementing gbm caret
#1 gradient boost set.seed(995) fitcontrol_1 <- traincontrol( method = "repeatedcv", number = 4, repeats = 5) gbm_model<- train(factor(india)~date+japan+hongkong+china+germany+france+euro+london+dowjones,data=train, method = "gbm", trcontrol = fitcontrol_1,verbose=true) prediction_gbm= predict(gbm_model,test) solution <- data.frame(org_bse = test$india, gbm = prediction_gbm)
but i'm not getting output though kept verbose=true
#2 adaboost set.seed(995) fitcontrol_2 <- traincontrol( method = "repeatedcv", number = 5, repeats = 5) ada_model<- train(factor(india)~date+japan+hongkong+china+germany+france+euro+london+dowjones,data=train,method="adaboost.m1",trcontrol = fitcontrol_2,verbose=true) prediction_ada= predict(ada_model,test) solution<-cbind(solution,ada=prediction_ada)
i used following code reproduce problem:
library(caret) set.seed(995) train <- data.frame( cyl = as.factor(mtcars$cyl), vs = as.factor(mtcars$vs), = as.factor(mtcars$am), gear = as.factor(mtcars$gear), carb = as.factor(mtcars$carb)) fitcontrol_2 <- traincontrol(method = "repeatedcv", number = 2, repeats = 1) ada_model<- train( cyl ~ vs + + gear + carb, data = train, method ="adaboost.m1", trcontrol = fitcontrol_2, verbose = true)
for me, "adaboost.m1" training ran ten minutes before decided stop it. added tuning grid specified below, , got result within minute. recommend try adjust code in similar fashion:
library(caret) set.seed(995) train <- data.frame( cyl = as.factor(mtcars$cyl), vs = as.factor(mtcars$vs), = as.factor(mtcars$am), gear = as.factor(mtcars$gear), carb = as.factor(mtcars$carb)) fitgrid_2 <- expand.grid(mfinal = (1:3)*3, # new! maxdepth = c(1, 3), # ...and coeflearn = c("breiman")) # ...and fitcontrol_2 <- traincontrol(method = "repeatedcv", number = 2, repeats = 1) ada_model <- train( cyl ~ vs + + gear + carb, data = train, method ="adaboost.m1", trcontrol = fitcontrol_2, tunegrid = fitgrid_2, #and new, too! verbose = true)
let me know if solves problem.
Comments
Post a Comment