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

后端 未结 4 1018
天命终不由人
天命终不由人 2021-02-04 08:02

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:35

    One way to save a model (in Scala; but probably is similar in Python):

    // persist model to HDFS
    sc.parallelize(Seq(model), 1).saveAsObjectFile("linReg.model")
    

    Saved model can then be loaded as:

    val linRegModel = sc.objectFile[LinearRegressionModel]("linReg.model").first()
    

    See also related question

    For more details see (ref)

提交回复
热议问题