📜  加载保存的模型 pyspark - 任何代码示例

📅  最后修改于: 2022-03-11 14:59:53.540000             🧑  作者: Mango

代码示例1
print(spark.version)
2.4.3

# fit model
cvModel = cv_grid.fit(train_df)

# save best model to specified path
mPath =  "/path/to/model/folder"
cvModel.bestModel.write().overwrite().save(mPath)

# read pickled model via pipeline api
from pyspark.ml.pipeline import PipelineModel
persistedModel = PipelineModel.load(mPath)

# predict
predictionsDF = persistedModel.transform(test_df)