我创建了一个混合了scikit学习预处理和keras的管道模型。
scaler = StandardScaler()
clf = KerasRegressor(build_fn=build_model,epochs=1000,validation_split=0.2, batch_size=100, callbacks=[print_dot,plot_losses], verbose=1)))
pipeline = Pipeline([
('preprocess',scaler),
('clf',clf)
])
import time
start = time.time()
pipeline.fit(X_train,y_train)
end = time.time()
print(end-start)
此代码有效,我也可以调用transform pipe方法
predictions = pipeline.predict(X_test).flatten()
问题是我需要将Pipeline保存为HD5模型,以便可以在运行时将未预处理的值提供给模型-
这可能吗 如果不是,托管此管道的方法是什么?
因此,以下问题仅解决了仅保存模型而没有预处理管道的问题- 我也想保存预处理管道-
How to save Scikit-Learn-Keras Model into a Persistence File (pickle/hd5/json/yaml)
@danyfang有助于发现这个问题
how to save a scikit-learn pipline with keras regressor inside to disk?
该问题将管道分别存储为.pkl文件。因此需要查看pk1如何转换为pmml