{"action":"created","issue":{"url":"https://api.github.com/repos/topepo/caret/issues/90","labels_url":"https://api.github.com/repos/topepo/caret/issues/90/labels{/name}","comments_url":"https://api.github.com/repos/topepo/caret/issues/90/comments","events_url":"https://api.github.com/repos/topepo/caret/issues/90/events","html_url":"https://github.com/topepo/caret/issues/90","id":52968226,"number":90,"title":"Trimming the final fit to reduce memory usage","user":{"login":"nkurz","id":122253,"avatar_url":"https://avatars.githubusercontent.com/u/122253?v=3","gravatar_id":"","url":"https://api.github.com/users/nkurz","html_url":"https://github.com/nkurz","followers_url":"https://api.github.com/users/nkurz/followers","following_url":"https://api.github.com/users/nkurz/following{/other_user}","gists_url":"https://api.github.com/users/nkurz/gists{/gist_id}","starred_url":"https://api.github.com/users/nkurz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nkurz/subscriptions","organizations_url":"https://api.github.com/users/nkurz/orgs","repos_url":"https://api.github.com/users/nkurz/repos","events_url":"https://api.github.com/users/nkurz/events{/privacy}","received_events_url":"https://api.github.com/users/nkurz/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/topepo/caret/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2014-12-27T23:07:36Z","updated_at":"2015-04-20T01:33:46Z","closed_at":"2015-04-20T01:33:46Z","body":"R has a well deserved reputation as being a memory hog when training models.  In part this is because the defaults tend toward keeping everything that might be used in the theory that this is easier for the user than explicitly specifying which parts they want to keep.   When training a single model, this is usually acceptable, since less memory is used by the result than is needed during the fit.   But in cases where multiple models are fit in succession, one can quickly run out of memory unless the unused portions of the result are immediately nulled.  \r\n\r\nThe solution isn't too difficult[1], but the problem is that each model may require that slightly different pieces be kept for prediction to work, and each model may have different items that should be removed.   Standardizing each underlying package is at this point an impossible task.  But since Caret is already providing a unified interface on top of these disparate models, it is perfectly positions to fix this problem.  It would only require adding a 'trim' method to the interface that already exists for each wrapped model.   \r\n\r\n@az0 brought this up in #76, but there didn't seem to be a clear resolution. @zachmayer and @jknowles discuss their intent to handle this in https://github.com/zachmayer/caretEnsemble/issues/69, but Caret seems like a much better place to put such functionality.  If it's not in Caret itself, every other package that deals with collections of Caret models would  have to add its own ersatz version for some subset of models.  \r\n\r\nWould it be possible to add this functionality to Caret?  Ideally, this trimming would happen by default before a model is returned from 'fit', and an explicit 'trim=FALSE' type argument would be required prevent it from happening.   Or it could be specified as a generic postProcessing step that defaults to trim.model.  Either of these could be added immediately with default method does nothing, and per model trimming could be added as time goes on.\r\n\r\n[1] http://www.win-vector.com/blog/2014/05/trimming-the-fat-from-glm-models-in-r/\r\n"},"comment":{"url":"https://api.github.com/repos/topepo/caret/issues/comments/94333090","html_url":"https://github.com/topepo/caret/issues/90#issuecomment-94333090","issue_url":"https://api.github.com/repos/topepo/caret/issues/90","id":94333090,"user":{"login":"topepo","id":5731043,"avatar_url":"https://avatars.githubusercontent.com/u/5731043?v=3","gravatar_id":"","url":"https://api.github.com/users/topepo","html_url":"https://github.com/topepo","followers_url":"https://api.github.com/users/topepo/followers","following_url":"https://api.github.com/users/topepo/following{/other_user}","gists_url":"https://api.github.com/users/topepo/gists{/gist_id}","starred_url":"https://api.github.com/users/topepo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/topepo/subscriptions","organizations_url":"https://api.github.com/users/topepo/orgs","repos_url":"https://api.github.com/users/topepo/repos","events_url":"https://api.github.com/users/topepo/events{/privacy}","received_events_url":"https://api.github.com/users/topepo/received_events","type":"User","site_admin":false},"created_at":"2015-04-20T01:33:46Z","updated_at":"2015-04-20T01:33:46Z","body":"This has been implemented for models `bayesglm`, `C5.0`, `C5.0Cost`, `C5.0Rules`, `C5.0Tree`, `glm`, `glmnet`, `rpart`, `rpart2`, and `treebag`. The current regression tests are passing.\r\n\r\nI'm going to close this and we can open new issues for specific models. "}}