title: Pyspark ML - How to save pipeline and RandomForestClassificationModel
body: <p>I unable to save random forest model generated using ml package of python/spark.</p>
  
  <pre><code>&gt;&gt;&gt; rf = RandomForestClassifier(labelCol="label", featuresCol="features")
  &gt;&gt;&gt; pipeline = Pipeline(stages=early_stages + [rf])
  &gt;&gt;&gt; model = pipeline.fit(trainingData)
  &gt;&gt;&gt; model.save("fittedpipeline")
  </code></pre>
  
  <blockquote>
    <p>Traceback (most recent call last):   File "", line 1, in
     AttributeError: 'PipelineModel' object has no attribute
    'save'</p>
  </blockquote>
  
  <pre><code>&gt;&gt;&gt; rfModel = model.stages[8]
  &gt;&gt;&gt; print(rfModel)
  </code></pre>
  
  <p>RandomForestClassificationModel (uid=rfc_46c07f6d7ac8) with 20 trees</p>
  
  <pre><code>&gt;&gt; rfModel.save("rfmodel")
  </code></pre>
  
  <blockquote>
    <p>Traceback (most recent call last):   File "", line 1, in
     AttributeError: 'RandomForestClassificationModel' object has
    no attribute 'save'**</p>
  </blockquote>
  
  <p>Also tried by pass 'sc' as first parameter to save method.</p>