# NOT RUN {
# fit a Random Forest Regression Model
df <- createDataFrame(longley)
model <- spark.randomForest(df, Employed ~ ., type = "regression", maxDepth = 5, maxBins = 16)
# get the summary of the model
summary(model)
# make predictions
predictions <- predict(model, df)
# save and load the model
path <- "path/to/model"
write.ml(model, path)
savedModel <- read.ml(path)
summary(savedModel)
# fit a Random Forest Classification Model
df <- createDataFrame(iris)
model <- spark.randomForest(df, Species ~ Petal_Length + Petal_Width, "classification")
# }
Run the code above in your browser using DataLab