Prradep Prradep - 27 days ago 13
R Question

How to share trained logistic models with others?

I have 5 logistic models trained using the private data. I want them to be validated on another private data by another member. How do I share share the trained models such that they can be evaluated on another system running an arbitrary version of R and packages (i.e. as portably as possible)? I know about

.RData
files, but they don't solve the dependency or data dependency issue.

Edit:
Tried the approach mentioned using
save
,
load
like below

save(Model1, file = "my_model1.test.rda")
model_diff <- load('my_model1.test.rda')
model_diff
[1] "Model1"


But the loaded model
model_diff
contained string
"Model1"
instead of the contents of it.

Answer

If anyone looking for answer, models can be saved using saveRDS()

saveRDS(lm.model, 'my_model.rds')

and load them in different session using readRDS() function

Model_load <- readRDS('my_model.rds')

based on m-dz's answer.