I have made an LDA model in R using MASS.
set.seed(1) # for reproducibility
library(MASS)
mydata <- data.frame(Segments=sample(1:4, 15, replace=TRUE),
var1=sample(1:7, 15, replace=TRUE),
var2=sample(1:7, 15, replace=TRUE),
var3=sample(1:6, 15, replace=TRUE),
var4=sample(1:2, 15, replace=TRUE))
mymodel <- lda(Segments~., data=mydata)
I know that if I want to run this model on different data, I can use predict
, e.g.
set.seed(10)
mydata2 <- data.frame(Segments=sample(1:4, 15, replace=TRUE),
var1=sample(1:7, 15, replace=TRUE),
var2=sample(1:7, 15, replace=TRUE),
var3=sample(1:6, 15, replace=TRUE),
var4=sample(1:2, 15, replace=TRUE))
newmodel <- predict(mymodel, newdata = mydata2)
newmodel$class # View predicted groups
I would like to make the model available for other people to use on their own data. However, I don't want to share my data that I used to build the model. Is there some way that I can export this model in a sharable way? And how would other people go about importing it?
For example, is it possible to export the model as a csv and for someone else to import it in a way that R recognises it as a model? The idea is that they will be able to use predict
with their own data and my model.