What is the right way to save\load models in Spark\PySpark

后端 未结 4 1652
一向
一向 2021-02-04 08:11

I\'m working with Spark 1.3.0 using PySpark and MLlib and I need to save and load my models. I use code like this (taken from the official documentation )

from p         


        
4条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-04 08:34

    Use pipeline in ML to train the model, and then use MLWriter and MLReader to save models and read them back.

    from pyspark.ml import Pipeline
    from pyspark.ml import PipelineModel
    
    pipeTrain.write().overwrite().save(outpath)
    model_in = PipelineModel.load(outpath)
    

提交回复
热议问题