How to save a custom transformer in sklearn?

后端 未结 2 972
轮回少年
轮回少年 2021-02-19 09:17

I am not able to load an instance of a custom transformer saved using either sklearn.externals.joblib.dump or pickle.dump because the original definiti

相关标签:
2条回答
  • 2021-02-19 09:53

    sklearn.preprocessing.StandardScaler works because the class definition is available in the sklearn package installation, which joblib will look up when you load the pickle.

    You'll have to make your CustomTransformer class available in the new session, either by re-defining or importing it.

    0 讨论(0)
  • 2021-02-19 09:56

    It works for me if I pass my transform function in sklearn.preprocessing.FunctionTranformer() and if I save the model using dill.dump() and dill.load a ".pk" file.

    Note: I have included the tranform function into a sklearn pipeline with my classifier.

    0 讨论(0)
提交回复
热议问题