Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabling serialization of prediction models #129

Open
JocaPC opened this issue May 15, 2016 · 0 comments
Open

Enabling serialization of prediction models #129

JocaPC opened this issue May 15, 2016 · 0 comments

Comments

@JocaPC
Copy link

JocaPC commented May 15, 2016

When I try to serialize and unserialize a prediction model, I'm getting an error when I try to predict a value:

eruption.lm = lm(eruptions ~ waiting, data=faithful) 
json<-serializeJSON(eruption.lm)
lin.model<-unserializeJSON(json)

newdata = data.frame(waiting=80)
predict(lin.model, newdata)
# Error:
# Error in eval(expr, envir, enclos) : could not find function "list"

Prediction model can be successfully unserialized if I put the following line after unserialize;

attr(lin.model$terms, ".Environment") <- .GlobalEnv

It would be nice if this could work by default. Problem and solution is described here:
http://stackoverflow.com/questions/37236806/r-serialize-r-models-as-json/37237530#37237530

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant