https://kedro.org/ logo
#questions
Title
# questions
h

Harry Vargas Rodríguez

06/29/2023, 1:50 PM
Hello everyone. I am trying to upload a model I created using kedro, this is sklearn object. But I noticed this artefact can´t be loaded outside my kedro project. When I try to upload using pickle.load( ) it fails and the error says I don´t have the module I've created in project/src.
model = pickle.load(open('models/model.pkl','rb'))
This is how my catalog looks like
best_model:
type: pickle.PickleDataSet
filepath: models/model.pkl
layer: models
It works just fine after I load kedro using %load_ext kedro.ipython Thanks in advance for your help
d

datajoely

06/29/2023, 1:54 PM
are you using the same version of python / virtual environment?
h

Harry Vargas Rodríguez

06/29/2023, 2:09 PM
@datajoely Yes, i am working in the same env
@Nok Lam Chan interesting. It is yet not really clear to my why this pickle object needs those dependencies, I understand it needs libraries as sklearn where the class RandomForestClassifier is defined, but I don´t undesrtand why it depends on the package of my project
n

Nok Lam Chan

06/29/2023, 2:16 PM
I can’t see the code so I have no idea
probably because of how you import the module
if you always import from sklearn it shouldn’t be a problem
It may become a problem if you do that (I have not test it)
Copy code
# module_1.py
from sklearn import RandomForestClassifier
Copy code
# module_2.py
from module_1 import RandomForestClassifier
h

Harry Vargas Rodríguez

06/29/2023, 2:24 PM
Okey, I see. I'm going to check it!!