How to save and load MLLib model in Apache Spark?

后端 未结 1 1506
予麋鹿
予麋鹿 2020-12-14 04:47

I trained a classification model in Apache Spark (using pyspark). I stored the model in an object, LogisticRegressionModel. Now, I want to make pre

相关标签:
1条回答
  • 2020-12-14 05:08

    You can save your model by using the save method of mllib models.

    # let lrm be a LogisticRegression Model
    lrm.save(sc, "lrm_model.model")
    

    After storing it you can load it in another application.

    sameModel = LogisticRegressionModel.load(sc, "lrm_model.model")
    

    As @zero323 stated before, there is another way to achieve this, and is by using the Predictive Model Markup Language (PMML).

    is an XML-based file format developed by the Data Mining Group to provide a way for applications to describe and exchange models produced by data mining and machine learning algorithms.

    0 讨论(0)
提交回复
热议问题