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
Related
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
Previously sklearn worked without a hitch. Since yesterday however, I receive the error message
'cannot import name 'logger'' , when I try to import a sklearn module (originally RobustScaler, but it happens for all sklearn modules now.) error message.
My sklearn version is 0.21.3 and I've tried to update the module (Requirements were already up-to-date) and to uninstall and then reinstall the module. This did not work either.
Your help would be appreciated!
Regards,
RM
EDIT: I solved it. I had to upgrade the joblib module (Through the command prompt). My former version was joblib 0.12.5 and my new version is joblib 0.13.2. The update command was pip install -U joblib.
check if you use many environments. For example under Anaconda, you can create different env (ex. Python 3.7 or 2.6).
I'm trying to train a Caffe model. My .prototxt file uses custom Python Data and Loss layers.
When I execute the training command in terminal, however, this error is raised:
[libprotobuf FATAL google/protobuf/stubs/common.cc:61] This program requires version 3.2.0 of the Protocol Buffer runtime library, but the installed version is 2.6.1. Please update your library. If you compiled the program yourself, make sure that your headers are from the same version of Protocol Buffers as your link-time library. (Version verification failed in "google/protobuf/descriptor.pb.cc".)
terminate called after throwing an instance of 'google::protobuf::FatalException'
My Python Package Manager (pip) has version 3.2.0 of protobuf installed, but the system version is at 2.6.1 for a package called libprotoc. I am not sure how to specify that the pip protobuf version is the one I want to use for caffe.
On another computer which has version 3.3.0 of protobuf installed on pip and 2.6.1 for the system version, I was thrown the same error, except that it said the program required version 3.3.0 rather than version 3.2.0.
Best.
I ran into exactly the same issue today. The workaround that worked for me was to start the training from caffe's python interface as opposed to starting it directly from the shell. Example:
import caffe
weights = '../ilsvrc-nets/vgg16-fcn.caffemodel'
caffe.set_device(0)
caffe.set_mode_gpu()
solver = caffe.SGDSolver('solver.prototxt')
solver.net.copy_from(weights)
for _ in range(25):
solver.step(4000)
Off course the above is just an example/very barebones, you'll have to handle running against the validation set yourself but the pycaffe interface is quite flexible and allows you to do all that. You can find more details on how to use that here:
http://christopher5106.github.io/deep/learning/2015/09/04/Deep-learning-tutorial-on-Caffe-Technology.html
I went around it by installing the same version of protobuf via pip, as the one from apt-get.
pip install protobuf==2.6
Alternative (which I wanted to avoid) was to install protobuf from sources.
https://github.com/google/protobuf/blob/master/src/README.md
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
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