Save model without fitted values in R -


let's have linear regression model this

a <- rnorm(100) b <- rnorm(100) fit <- lm(a ~ b) 

the fit object list contains coefficients , data , fitted values , on , forth. however, if want predict on unseen data need model itself, coefficients. in example doesn't matter, have models (unnecessarily) hundreds of mb big.

how can keep stuff needed predict on unseen data?

...and still able use predict()

you right elements of list can replaced null. should not impact predict , therefore used correctly. have make sure elements not needed in predict.

you instance :

fit$data <- null fit$y <- null fit$linear.predictors <- null fit$weights <- null fit$fitted.values <- null fit$model <- null fit$prior.weights <- null fit$residuals <- null fit$effects <- null 

more details provided in link. http://blog.yhat.com/posts/reducing-your-r-memory-footprint-by-7000x.html


Comments

Popular posts from this blog

string - Using python and postgres, variables within execute function? -

android - How to get the Uri path from a ImageView? -