Search code examples
machine-learningscikit-learnpycharmdecision-treejoblib

Why pycharm having error while loading .joblib file


I have a trained decision tree model file music-recommender.joblib. When I am using Jupyter notebook, I am able to load this trained model successfully and able to do prediction. But the same code I used in pycharm and it is showing error.

In Jupyter Notebook

enter image description here

As you can see, it is predicting correctly based on the trained model

In PyCharm

enter image description here

Does anyone knows why is it this way?


Solution

  • You call the joblib.load() method but do not assign the output to any variable. And in the next step you are trying to use the model variable which is not defined anywhere above and hence the error.

    You need to do:

    model = joblib.load(...)