Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 909
Artem Nepo Avatar asked Nov 17 '16 21:11

Artem Nepo


2 Answers

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.

like image 95
maxymoo Avatar answered Oct 20 '22 08:10

maxymoo


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.

like image 30
Fruitspunchsamurai Avatar answered Oct 20 '22 06:10

Fruitspunchsamurai