我有一个 PySpark 代码来训练 H2o DRF 模型。我需要将这个模型保存到磁盘然后加载它。
from pysparkling.ml import H2ODRF
drf = H2ODRF(featuresCols = predictors,
labelCol = response,
columnsToCategorical = [response])
我找不到任何文件,所以我在这里问这个问题。
我认为关于部署管道模型的文档部分可能是相关的:https://docs.h2o.ai/sparkling-water/2.3/latest-stable/doc/deployment/pysparkling_pipeline.html
管道可能不是您正在寻找的,具体取决于用例。
以下内容可能适用于您的用例。
drf = H2ODRF(featuresCols = predictors,
labelCol = response,
columnsToCategorical = [response])
pipeline = Pipeline(stages=[drf])
model = pipeline.fit(data)
model.save("drf_model")
model.save("mySavePath")
然后当您需要加载模型时:
model = pysparkling.ml.H2OMOJOModel.load("mySavePath")