{"action":"created","issue":{"url":"https://api.github.com/repos/zachmayer/caretEnsemble/issues/179","labels_url":"https://api.github.com/repos/zachmayer/caretEnsemble/issues/179/labels{/name}","comments_url":"https://api.github.com/repos/zachmayer/caretEnsemble/issues/179/comments","events_url":"https://api.github.com/repos/zachmayer/caretEnsemble/issues/179/events","html_url":"https://github.com/zachmayer/caretEnsemble/issues/179","id":124331591,"number":179,"title":"Stacking Regressions using caretEnsemble function","user":{"login":"Mosquito00","id":16487745,"avatar_url":"https://avatars.githubusercontent.com/u/16487745?v=3","gravatar_id":"","url":"https://api.github.com/users/Mosquito00","html_url":"https://github.com/Mosquito00","followers_url":"https://api.github.com/users/Mosquito00/followers","following_url":"https://api.github.com/users/Mosquito00/following{/other_user}","gists_url":"https://api.github.com/users/Mosquito00/gists{/gist_id}","starred_url":"https://api.github.com/users/Mosquito00/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mosquito00/subscriptions","organizations_url":"https://api.github.com/users/Mosquito00/orgs","repos_url":"https://api.github.com/users/Mosquito00/repos","events_url":"https://api.github.com/users/Mosquito00/events{/privacy}","received_events_url":"https://api.github.com/users/Mosquito00/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-12-30T10:35:58Z","updated_at":"2016-01-02T09:23:10Z","closed_at":null,"body":"Dear all, \r\n\r\nI would like to use the code from zachmayer. Unfortunately, I get an error in the following line:\r\n\r\n\"greedy = caretEnsemble(all.models, iter=1000L)\"\r\n\r\nError: x$control$savePredictions ist nicht TRUE\r\n\r\nHowever, I tried to solve the issue in the following line: \r\n\r\n\"all.models = caretList(X[train,], Y[train], trControl=myControl,methodList=c('gbm', 'blackboost'))\"\r\n\r\nThis line produces also a warning message and says: \r\n\r\nError in sensitivity.default(data[, \"pred\"], data[, \"obs\"], lev[1]) : \r\n  inputs must be factors\r\nIn addition: Warning message:\r\nIn train.default(list(crim = c(0.03237, 0.06905, 0.02985, 0.08829,  :\r\n  cannnot compute class probabilities for regression\r\n\r\nTherefore, I thought that the error lies in the second line and I tried to convert X[train,] and Y[train] into factors, but this did not work out as I assumed. \r\n\r\nThe code is the following: \r\n\r\nset.seed(40) \r\n\r\nlibrary(caret)\r\nlibrary(devtools)\r\nlibrary(caretEnsemble)\r\n\r\n#Data\r\nlibrary(mlbench)\r\ndata(BostonHousing2)\r\n\r\nX = model.matrix(cmedv~crim+zn+indus+chas+nox+rm+age+dis+\r\n                    rad+tax+ptratio+b+lstat+lat+lon, BostonHousing2)[,-1]\r\nX = data.frame(X)\r\n\r\nY = BostonHousing2$cmedv\r\n\r\ntrain = runif(nrow(X)) <= .66\r\n\r\nfolds=5\r\nrepeats=1\r\n\r\nfold cross-validations are used as the resampling scheme.\r\nmyControl = trainControl(method='cv', summaryFunction=twoClassSummary,\r\n                         number = folds,\r\n                         repeats = repeats,\r\n                         classProbs=TRUE,\r\n                         savePredictions=TRUE,\r\n                         index=createMultiFolds(Y[train], k=folds, times=repeats))\r\n                         \r\nPP = c('center', 'scale')\r\n\r\nnames(all.models) = sapply(all.models, function(x) x$method)\r\nsort(sapply(all.models, function(x) min(x$results$RMSE)))\r\n\r\nregression, elastic net regression, or greedy optimization.\r\nprint(all.models)\r\n\r\ngreedy = caretEnsemble(all.models, iter=1000L)\r\nprint(greedy)\r\nsort(greedy$weights, decreasing=TRUE)\r\ngreedy$error\r\n\r\nAny help would be appreciated.\r\n"},"comment":{"url":"https://api.github.com/repos/zachmayer/caretEnsemble/issues/comments/168375039","html_url":"https://github.com/zachmayer/caretEnsemble/issues/179#issuecomment-168375039","issue_url":"https://api.github.com/repos/zachmayer/caretEnsemble/issues/179","id":168375039,"user":{"login":"Mosquito00","id":16487745,"avatar_url":"https://avatars.githubusercontent.com/u/16487745?v=3","gravatar_id":"","url":"https://api.github.com/users/Mosquito00","html_url":"https://github.com/Mosquito00","followers_url":"https://api.github.com/users/Mosquito00/followers","following_url":"https://api.github.com/users/Mosquito00/following{/other_user}","gists_url":"https://api.github.com/users/Mosquito00/gists{/gist_id}","starred_url":"https://api.github.com/users/Mosquito00/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mosquito00/subscriptions","organizations_url":"https://api.github.com/users/Mosquito00/orgs","repos_url":"https://api.github.com/users/Mosquito00/repos","events_url":"https://api.github.com/users/Mosquito00/events{/privacy}","received_events_url":"https://api.github.com/users/Mosquito00/received_events","type":"User","site_admin":false},"created_at":"2016-01-02T09:23:09Z","updated_at":"2016-01-02T09:23:09Z","body":"Hello zachmayer, \r\n\r\nI already provided the code above...\r\n\r\nHere is the code: \r\n\r\nset.seed(40)\r\n\r\nlibrary(caret)\r\nlibrary(devtools)\r\nlibrary(caretEnsemble)\r\n\r\n#Data\r\nlibrary(mlbench)\r\ndata(BostonHousing2)\r\n\r\nX = model.matrix(cmedv~crim+zn+indus+chas+nox+rm+age+dis+\r\nrad+tax+ptratio+b+lstat+lat+lon, BostonHousing2)[,-1]\r\nX = data.frame(X)\r\n\r\nY = BostonHousing2$cmedv\r\n\r\ntrain = runif(nrow(X)) <= .66\r\n\r\nfolds=5\r\nrepeats=1\r\n\r\nfold cross-validations are used as the resampling scheme.\r\nmyControl = trainControl(method='cv', summaryFunction=twoClassSummary,\r\nnumber = folds,\r\nrepeats = repeats,\r\nclassProbs=TRUE,\r\nsavePredictions=TRUE,\r\nindex=createMultiFolds(Y[train], k=folds, times=repeats))\r\n\r\nPP = c('center', 'scale')\r\n\r\nnames(all.models) = sapply(all.models, function(x) x$method)\r\nsort(sapply(all.models, function(x) min(x$results$RMSE)))\r\n\r\nregression, elastic net regression, or greedy optimization.\r\nprint(all.models)\r\n\r\ngreedy = caretEnsemble(all.models, iter=1000L)\r\nprint(greedy)\r\nsort(greedy$weights, decreasing=TRUE)\r\ngreedy$error\r\n\r\nThank you."}}