Tag Archives: ImportError: No module named model_selection

Pycharm Error: ImportError: No module named model_selection

first of all, I want to explain that I have this problem because I need to use train_ test_ Split method, the specific reference is:

from sklearn.model_selection import train_test_split

this error occurred:

ImportError: No module named model_selection

I checked on the Internet and found out the cause of the problem. One thing Dashen gave me was that there was a problem with my sklearn version, which was train before version v0.18_ test_ Split is placed in cross_ In the validation module, now, there are two solutions to this problem:

Method 1.

will:

from sklearn.model_selection import train_test_split

TO:

from sklearn.cross_validation import train_test_split

 

Method 2.

Upgrade sklearn to v0.18 or above

If your pychar compilation environment is Anaconda’s python, enter
in the anaconda prompt operation line

The CONDA update scikit learn command updates the version of sklearn. Before updating, you will be prompted to what version to update

Or enter PIP install — upgrade scikit learn to update the version
as well