Search code examples
apache-sparkapache-spark-ml

Can I append a new transformer or estimator to the pipeline?


In Spark ML, Can I load saved pipeline and append a new transformer to this loaded pipeline?


Solution

  • You can use the getStages method on the Pipeline object to get an Array[PipelineStage] then append the desired PipelineStage using the :+ scala operator.

    val pipeline = //your pipeline
    val newStage = //you new stage
    pipeline.getStages :+ new Stage
    

    Hope it helps. Best Regards