Importing a pickle model in Dataiku

Zyad
Level 1
Importing a pickle model in Dataiku

I have a pickle saved OLS model (statsmodels) developed outside Dataiku. I uploaded it on a folder in dataiku but wasn't able to use it from a jupyter notebook.

I have tried those solutions:

import sklearn model trained outside of Dataiku into Dataiku - Dataiku Community

I have tried this but I wasn't able to use after as a model:

folder = dataiku.Folder("Models")
with folder.get_download_stream('linear_regression.pickle') as f:
model = f.read()

What is Dataiku wrapup library for this situation?

 

0 Kudos
1 Reply
JordanB
Dataiker

Hi @Zyad,

The correct way to load a pickle file would be to add:

folder = dataiku.Folder("Models")
with folder.get_download_stream('linear_regression.pickle') as f:
   model = pickle.load(f)

Also, add "import pickle" along with other libraries. The pickled model should come from the same version of scikit-learn as the one installed in the Python code env you're using here.

Let me know if you have any questions.

Thanks!

Jordan

0 Kudos