title: How to save RandomForestClassifier Spark model in scala?
body: <p>I built a random forest model using the following code: </p>
  
  <pre><code>import org.apache.spark.ml.classification.RandomForestClassificationModel
  import org.apache.spark.ml.classification.RandomForestClassifier
  val rf = new RandomForestClassifier().setLabelCol("indexedLabel").setFeaturesCol("features")
  val labelConverter = new    IndexToString().setInputCol("prediction").setOutputCol("predictedLabel").setLabels(labelIndexer.labels)
  val training = labelIndexer.transform(df)
  val model = rf.fit(training)
  </code></pre>
  
  <p>now I want to save the model in order to predict later using the following code:</p>
  
  <pre><code>val predictions: DataFrame = model.transform(testData)
  </code></pre>
  
  <p>I've looked into Spark documentation <a href="https://spark.apache.org/docs/latest/api/scala/index.html#org.apache.spark.ml.classification.RandomForestClassifier" rel="noreferrer">here</a> and didn't find any option to do that. Any idea? 
  It took me a few hours to build the model , if Spark is crushing I won't be able to get it back. </p>