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

Is there a better way to structure post methods in Class Based Views -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -