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

前端 未结 2 1080
梦谈多话
梦谈多话 2021-02-01 20:59

I have a scikit-learn pipline with kerasRegressor in it:

estimators = [
    (\'standardize\', StandardScaler()),
    (\'mlp\', KerasRegressor(build_fn=baseline_m         


        
2条回答
  •  囚心锁ツ
    2021-02-01 21:19

    Keras is not compatible with pickle out of the box. You can fix it if you are willing to monkey patch: https://github.com/tensorflow/tensorflow/pull/39609#issuecomment-683370566.

    You can also use the SciKeras library which does this for you and is a drop in replacement for KerasClassifier: https://github.com/adriangb/scikeras

    Disclosure: I am the author of SciKeras as well as that PR.

提交回复
热议问题