3

I have created a pipeline model mixing scikit learn preprocessing and 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)

This code works and I can call the transform pipeline method as well

predictions = pipeline.predict(X_test).flatten()

The problem is I need to save Pipeline as an HD5 model so that non-pre-processed values can be given to the model during runtime -

Is this possible if not what is the method of hosting this pipeline?

So the question below only solves the problem of saving just the model without the pre-processing pipeline - I want to save the pre-processing pipeline as well -

How to save Scikit-Learn-Keras Model into a Persistence File (pickle/hd5/json/yaml)

@danyfang was helpful in finding this question

how to save a scikit-learn pipline with keras regressor inside to disk?

The problem it stores pipeline as .pkl file separately. So need to see how pk1 is converted to pmml

Leothorn
  • 1,345
  • 1
  • 23
  • 45
  • 1
    There is a similar question with an answer. https://stackoverflow.com/questions/37984304/how-to-save-a-scikit-learn-pipline-with-keras-regressor-inside-to-disk – Danny Fang Apr 03 '19 at 08:12
  • Thanks this does not answer my question of storing the pipeline as hd5 or pmml either . But a good find . including in question – Leothorn Apr 03 '19 at 10:12
  • It is a long shot but this post might help. https://stackoverflow.com/questions/54012769/saving-an-sklearn-functiontransformer-with-the-function-it-wraps/54055928#54055928 – KRKirov Apr 03 '19 at 11:16

0 Answers0