我使用Scikit系列化模型了解:
#Generate data
import pandas as pd
import numpy as np
df = pd.DataFrame(np.random.randn(100, 5), columns=['a', 'b', 'c', 'd', 'e'])
df["y"] = (df['a'] > 0.5).astype(int)
df.head()
from mleap.sklearn.ensemble.forest import RandomForestClassifier
forestModel = RandomForestClassifier()
forestModel.mlinit(input_features='a',
feature_names='a',
prediction_column='e_binary')
forestModel.fit(df[['a']], df[['y']])
forestModel.serialize_to_bundle("/dbfs/FileStore/tables/mleaptestmodelforest", "model.json")
当我尝试用Pyspark阅读时:
from pyspark.ml.classification import RandomForestClassificationModel
model = RandomForestClassificationModel.deserializeFromBundle("file:/dbfs/FileStore/tables/mleaptestmodelforest")
我有一个错误:
java.nio.file.NoSuchFileException: /dbfs/FileStore/tables/mleaptestmodelforest/bundle.json
我没有“bundle.json”
你能帮我吗? 是否真的有可能使用Scikit Learn对模型进行序列化,并使用Pyspark对其进行反序列化
目前没有回答
相关问题 更多 >
编程相关推荐