Artem Nepo
Artem Nepo

Reputation: 473

How to upgrade the classifier to the latest version of scikit-learn

I have a big trained TfidfVectorizer dumped with joblib.dump. It was created on my laptop with scikit-learn version 0.18. When I'm trying to put it to my server where the newest version of scikit-learn 0.18.1 is installed I'm getting warned with the following:

/usr/local/lib/python2.7/dist-packages/sklearn/base.py:315: UserWarning: Trying to unpickle estimator TfidfTransformer from version 0.18 when using version 0.18.1. This might lead to breaking code or invalid results. Use at your own risk.
  UserWarning)
/usr/local/lib/python2.7/dist-packages/sklearn/base.py:315: UserWarning: Trying to unpickle estimator TfidfVectorizer from version 0.18 when using version 0.18.1. This might lead to breaking code or invalid results. Use at your own risk.
  UserWarning) 

Is there a natural way to upgrade my TfidfVectorizer to prevent any problems?

Should I better uninstall scikit-learn 0.18.1 and install version 0.18 to the server instead?

Upvotes: 22

Views: 68516

Answers (5)

parastoo hedayati
parastoo hedayati

Reputation: 362

you should install the version of scikit that your project use.

first uninstall scikit :

pip uninstall scikit-learn

then install correct version like that:

pip install -v scikit-learn==0.18

Upvotes: -1

Itishree Behera
Itishree Behera

Reputation: 9

Just uninstall and reinstall the latest Scikit (or upgrade to the latest version) . And then train the model once again and that will generate a new joblib model. This will surely work.

Upvotes: -1

Dimitri
Dimitri

Reputation: 9

You should be able to circumvent this problem by first updating sklearn to the latest version, then loading the pickled objects with joblib.load and dumping it with joblib.dump. When I've done this, I no longer receive a warning.

Upvotes: -1

maxymoo
maxymoo

Reputation: 36545

Yes you should install the same version on your server as you used for development, best practice is to use a requirements.txt for all the requirements of your project and install a new environment on your server using conda or virtualenv, this will save you the problems of manually setting this stuff up.

Upvotes: 16

Fruitspunchsamurai
Fruitspunchsamurai

Reputation: 404

This link gives you instructions on how to upgrade.

pip install -U scikit-learn

The above command should upgrade whatever your current version of scikit is to the latest version. Depending on what you are doing with the tfidf vectorizer, you may or may not have issues; I would recommend staying updated with new releases. So, you would be better off making sure your server and computer both run the latest sci-kit.

Upvotes: 1

Related Questions