Search code examples
apache-sparkapache-spark-mllibsparkr

SparkR save ML model


How to save a SparkR model and load the model separately and predict?
Spark version 2.0

# Load training data
 df <- read.df("data/mllib/sample_libsvm_data.txt", source = "libsvm")
 training <- df
 testing <- df

# Fit a random forest classification model with spark.randomForest
 model <- spark.randomForest(training, label ~ features, "classification", numTrees = 10)

# Model summary
 summary(model)



 ### Save and Load
 ??

# Prediction
 predictions <- predict(model, test)
 head(predictions)

Solution

  • I believe you are looking for read.ml(path) and write.ml(object, path)