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?
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.
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.
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.
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.
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
Related
I have some files with models serialized with pickle, but now when i try to unserialize them, i get:
UserWarning: Trying to unpickle estimator LogisticRegression from version 1.0.1 when using version 1.0.2. This might lead to breaking code or invalid results. Use at your own risk. For more info please refer to:
https://scikit-learn.org/stable/modules/model_persistence.html#security-maintainability-limitations
How can i specify colab to use that version of pickle
Pickle is part of The Python Standard Library, so you cannot change its version without changing your Python version. However, that warning message refers to the version of Scikit-learn, not pickle. You can install Scikit-learn 1.0.1 as follows:
!pip install scikit-learn==1.0.1
I created vritualenv for my project A. I ran the same project A after long time.
I was using same virtualenv for other projects as well ,so depending upon other requirements I have installed other libraries as well.
Now when I running project It gives me sklearn, which was working fine earlier.
What can be the reason now it gives import error with sklearn package?
Since you are using the code after a long time, I suspect your old code is outdated.
You can actually use import joblib directly instead of doing it using sklearn.externals, since it is deprecated in the latest version of scikitlearn.
DeprecationWarning: sklearn.externals.joblib is deprecated in 0.21 and will be removed in 0.23. Please import this functionality directly from joblib, which can be installed with: pip install joblib.
You might want to run this first:
pip install joblib
I want to use sklearn.metrics plot_confusion_matrix in Google Colab. It comes with the latest stable update of sklearn 0.22.
https://scikit-learn.org/stable/auto_examples/model_selection/plot_confusion_matrix.html#sphx-glr-auto-examples-model-selection-plot-confusion-matrix-py
I tried this Make colab use the latest installation of a library
But in the end it shows the version of sklearn is still 0.21.
I uninstalled sklearn from colab like you do in the start of your image and reinstalled it again updating it as it is mentioned in sklearn documentation. The code I used was the following:
!pip uninstall scikit-learn -y
!pip install -U scikit-learn
After I checked if my version was updated with:
import sklearn
sklearn.__version__
'0.24.1'
Make sure to hit Runtime > Restart Runtime
I am trying to develop some time-series sequence prediction, using the latest resources available. To that end, I did check the example code from TensorFlow time-series, but I'm getting this error:
AttributeError: module 'tensorflow.python.pywrap_tensorflow' has no attribute 'TFE_Py_RegisterExceptionClass'
I'm using Anaconda. The current environment is Python 3.5 and TensorFlow 1.2.1. Also tried TensorFlow 1.3, but nothing changed.
Here is the code I'm trying to run. I did not find anything useful related to the issue on Google. Any ideas on how to solve it?
As Conan.Net wrote:
I tried to remove/clean some environments from anaconda and install
all again and it work this time.
This solution worked for me as well, so though not ideal, it will solve the problem. If you are using anaconda, it might happen when installing some packages and then removing them (e.g. tensorflow vs tensorflow-gpu) leaves some dependencies hanging. In my case, I used:
conda remove --name py2_tf_gpu --all
then
conda create --name py2_tf_gpu python=2 anaconda pandas numpy scipy jupyter
source activate py2_tf_gpu
pip install --ignore-installed --upgrade tensorflow-gpu
pip currently installs a later(1.4) than anaconda(1.3) version and I had need for it.
Maybe the version of tensorflow doesn't match the version of keras.
Using a lower version of keras solve this problem
I have anaconda 2.7 for Windows 7, 64 bit. I wanted to upgrade my scikit-learn version from 0.15 to 0.16.1 but I had some connection problems so I could not follow the guide here: http://scikit-learn.org/dev/install.html#id1 (I tried several times...) . So I used scikit-learn-0.16.1.win-amd64-py2.7.exe (md5) downloaded from https://pypi.python.org/pypi/scikit-learn/0.16.1.
When I go to check the version of scikit learn in spider using the code:
import sklearn
sklearn.__version__
I read the exact version, that is: '0.16.1' but if I try to use:
from sklearn import cross_validation
I have the following error:
ImportError: cannot import name check_arrays
that means that actually, it doesn't use the version 0.16.1!
So how can I solve? I tried to unistall and install again but it is the same. Since I have network restriction I can't access to the web using the command windows.
Thank you
You can't upgrade a package installed with anaconda with pip. Just do conda update scikit-learn, see the installation docs