I am experimenting with some code that still uses the old sklearn module from sklearn.cross_validation import KFold. Instead I should use sklearn.model_selection, however this causes other errors inside the code.
I know version 0.17 of sklearn still has the depricated cross_validation. However I cannot install this using pip as it doesnt find that version.
I am using a virtuel envirement with python 3.3, how could I still use the older library?
Related
I had Python3.5.2 installed on /usr/bin/.
All the modules include scipy and numpy works well.
But, after I installed Python3.8 the modules scipy and numpy doesn't work.
I saw that Python3.8 is in usr/local/bin instead usr/bin.
So, how can I run Python3.8 using all the modules like I used with Python3.5.2?
Python 3.8.0 was just released on 2019-10-14, so several modules are not yet supported (as of 2019-10-31). SciPy, Matplotlib, and SciKit-Learn are not yet supported. These may be supported by the time 3.8.1 is released in 2019-12-16.
Numpy and Pandas are supported, but for the others you will need to continue using a supported version of Python. To keep both versions on your machine, I would recommend using a virtual environment.
Could not import sklearn as well as scikit-learn in my pycharm IDE, almost I have worked with them for a year now. Could not fix the issue. Tried uninstalling and installing sklearn learn again and it install a version 0.0 :(
In all my other virtual environments also I could see sklearn as 0.0 version only (without updating it from anywhere!)
And I could see scikit-learn installed, but could not import as import scikitlearn
Any help would be appreciated!
Was using an older version of PyCharm since there was an issue in the debugging in the latest version. But when I tried the latest version the packages were able to be imported! Not sure what went wrong :/
I am trying to use Xgboost in GCP datalab. I have already installed sklearn but I keep getting the error :
" XGBoostError: sklearn needs to be installed in order to use this
module"
Below is the code I used:
import sklearn
!pip3 install xgboost
from xgboost.sklearn import XGBClassifier
model = XGBClassifier()
I have tried using Python v 2.7 instead, but no luck...does anyone know how to solve this issue in GCP Datalab?
I also faced the same issue, on python 3.7 32bit on ipython.
Solution: Uninstall the xgboost package by pip uninstall xgboost on terminal/cmd. Cross-check on the your console if you cannot import it. Now again install xgboost pip install xgboost or pip install xgboost-0.81-cp37-cp37m-win32.whl, given that you have already installed sklearn, it will work on newer console session.
xgboost wheel Link: https://pypi.org/project/xgboost/#files
I got the same error with a more complicated project, after releasing a new version suddenly it failed.
luckily in my case, I had docker images for each version, and was able to use pip freeze to see what changed.
In both version I used xgboost==0.81
In the version that worked I had scikit-learn==0.21.3 and in the new version it was scikit-learn==0.22
surprisingly enough, that's now what caused the issue. I've tried to uninstall xgboost like it was suggested here and reverted scikit-learn to the version is was originally on, and still no luck.
what did cause the issue was an update of numpy from 1.17.4 to 1.18.0.
reverting it solved it for me (not sure why)
this was python 3.6 on ubuntu
For me un- then re-installing first sklearn and then xgboost did the trick
I try to use
from gensim.sklearn_api import W2VTransformer
and get
ImportError: No module named 'gensim.sklearn_api'
I used
import gensim
import sklearn
from sklearn.base import BaseEstimator, TransformerMixin
and get the same.
In sklearn_api.w2vmodel – Scikit learn wrapper for word2vec model I could find no advice.
How to install gensim.sklearn_api?
#tursunWali
Class names seem to have changed from v1.0.5. Try calling TFIDF and other methods by prefixing them with do_, e.g. hero.do_tfidf.
Here's a minimal example:
df['pca']=(df['text'].pipe(hero.clean).pipe(hero.do_tfidf).pipe(hero.do_pca))
You can see all the class names in the package source code.
If you're using vanilla Python, pip install -U gensim.
After importing the "texthero" library. Its shown error message:
ModuleNotFoundError: No module named 'gensim.sklearn_api'
I have tried to install 'gensim.sklearn_api', but no such module available yet.
Also created the new anaconda environment for an older version of python-like 3.6 and 3.7 but it's has shown the same error message.
Finally, I have installed the older version of texthero and its work
pip install texthero==1.0.5
The older version of texthero==1.0.5 is very much compatible with python version like 3.6, 3.7 and 3.8
For me it was the version, try: pip install "gensim==3.8.3".
I just installed sklearn, my program runs no problem when I import it into the code. However, whenever I try to access the naive_bayes module, I get this error:
ImportError: No module named naive_bayes
Here's how I'm importing it:
from sklearn.naive_bayes import GaussianNB
Not sure where I'm going wrong, any help is much appreciated!
In the spirit of "turn it off, and turn it back on again" solutions, and given the fact that you're getting a Module has no attribute: __version__ when you try and print the scikit-learn version (which should be defined in any self-respecting Python module), I'm going to recommend you uninstall and reinstall scikit-learn:
pip uninstall sklearn
pip install sklearn
Run the following commands, and compare to the output provided, to make sure the package is behaving the way it should:
>>> import sklearn
>>> print(sklearn.__version__)
0.19.0
>>> print(sklearn.__file__)
/usr/local/lib/python3.6/site-packages/sklearn/__init__.py
>>>
The output from printing sklearn.__file__ does not need to match exactly, but it should at least print some location on your computer.
Also, check to make sure your pip matches your python. This depends on what platform you're on, but this mix of version 2 and version 3 sometimes creates a nasty cocktail. Executing pip --version should tell you which version of Python it is tied to.
$ which pip3
/usr/local/bin/pip3
$ pip3 --version
pip 9.0.1 from /usr/local/lib/python3.6/site-packages (python 3.6)
$ which python3
/usr/local/bin/python3
You should be OK with Python version 2, so long as things match.
(Soap box moment: move to Python 3 if you don't have a really good reason for sticking with Python 2!)
It seems that the sklearn installation does not include the naive_bayes in your installation. If the sklearn install correctly, it would say something like
ImportError: No module named 'sklearn.naive_bayes2'
However, in your case, the import error shows a bit different output. Please check the version and run the test file.
I had the same problem while installing sklearn and scikit-learn through pip.
I fixed the issue through the following steps
pip uninstall sklearn (if already installed)
pip uninstall scikit-learn( if already installed)
git clone scikit-learn
cd scikit-learn
python setup.py install
Hope this will help you.