Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 14271

joblib: Can not load dumped model from another subfolder of parent directory

$
0
0

I have train a small model and use joblib to save it.
But i get an error while trying to load it.
This is my structure of directory:

loader.pypackage    model_folder        __init__.py        model.py        model.pkl    predict_folder        __init__.py        predict.py

Inside the package.predict_folder.predict.py, i write a funtion to load the model.pkl.

from ..model import modelimport joblibimport sysdef predict(model_path):    # sys.path.append(model_path)    model = joblib.load(model_path)

Then inside the loader.py, I call that function.

from package.predict_folder.predict import predictpredict('package/model_folder/model.pkl')

But i get this error:ModuleNotFoundError: No module named 'model_folder'

I have tried to use sys to add path: sys.path.append('package/model_folder/model.pkl') like i commented it above. But nothing has changed.Can anyone help me ?


Viewing all articles
Browse latest Browse all 14271

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>