Hello everyone. I am trying to upload a model I cr...
# questions
h
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
are you using the same version of python / virtual environment?
h
@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
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
Okey, I see. I'm going to check it!!