Tpot: No module named model_selection?how fix it?

Created on 13 Nov 2016  ·  27Comments  ·  Source: EpistasisLab/tpot

"from sklearn.model_selection import train_test_split"
something wrong with this ,sklearn can't find the model_selection
BTW,train_test_split can be used by "from sklearn.cross_validation import train_test_split"

question

Most helpful comment

Yes, you should update to the latest version of scikit-learn. On your command line, enter:

pip install --upgrade scikit-learn

or

conda update scikit-learn

if you use the Anaconda distribution.

All 27 comments

+1

The train_test_split was moved to the model_selection from cross_validation in 0.18 of scikit-learn. Please update scikit-learn to 0.18.

Yes, you should update to the latest version of scikit-learn. On your command line, enter:

pip install --upgrade scikit-learn

or

conda update scikit-learn

if you use the Anaconda distribution.

@MrLevo520, did this solve your issue?

I was having the same issue and upgrading to 0.18 solved it.

@rhiever I had to conda update scikit-learn (sklearn wouldn't work)

Edited my comment above.

@rhiever When I try conda update scikit-learn, I am getting this error

`PackageNotInstalledError: Package is not installed in prefix.
prefix: /anaconda
package name: scikit-learn

`

Did you try conda update sklearn?

after updating the scikit learn when i was import i am getting the error like it
from sklearn.model_selection import cross_val_score

ImportError: cannot import name 'comb'

DeprecationWarning: This module was deprecated in version 0.18 in favor of the model_selection module into which all the refactored classes and functions are moved. Also note that the interface of the new CV iterators are different from that of this module. This module will be removed in 0.20.
"This module will be removed in 0.20.", DeprecationWarning)
THis keeps showing after I did the update

What version of TPOT and what version of sklearn are you using? Do you have
XGBoost installed, and if so, what version?

On Wed, Aug 8, 2018 at 10:59 PM Rootmannii notifications@github.com wrote:

DeprecationWarning: This module was deprecated in version 0.18 in favor of
the model_selection module into which all the refactored classes and
functions are moved. Also note that the interface of the new CV iterators
are different from that of this module. This module will be removed in 0.20.
"This module will be removed in 0.20.", DeprecationWarning)
THis keeps showing after I did the update


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/EpistasisLab/tpot/issues/314#issuecomment-411629287,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABo7t2IV9OORd2gEE-3PWqXjTu55BGTmks5uO7OJgaJpZM4Kwsbj
.

>

Cheers,

Randal S. Olson, Ph.D.

E-mail: [email protected] | Twitter: @randal_olson
https://twitter.com/randal_olson
http://www.randalolson.com

The former code "from sklearn.crossvalidation import traintest_split" has deprecated. The new one is below. I had the same problem, now it's gone.

"from sklearn.modelselection import traintest_split"

@cakmakaf

I am still facing the same issue

ModuleNotFoundError Traceback (most recent call last)
in ()
3 from sklearn.tree import DecisionTreeClassifier,_tree
4 import numpy as np
----> 5 from sklearn.modelselection import traintest_split
6 from sklearn import cross_validation
7 from sklearn.tree import export_graphviz

ModuleNotFoundError: No module named 'sklearn.modelselection'


NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.

To view examples of installing some common dependencies, click the
"Open Examples" button below.

@vaibhavagarwa @cakmakaf what is the version of scikit-learn in your environment?

The former code "from sklearn.crossvalidation import traintest_split" has deprecated. The new one is below. I had the same problem, now it's gone.

"from sklearn.modelselection import traintest_split"

the best answer

Hello guys i have the same problem knowing that the sklearn version is (0.21.2) and model selection worked before

@mhrihab I am also facing the same issue with the sklearn version (0.21.2) . model_selection is getting imported but not working

I am also having this issue even though my sklearn version is 0.21.2

Hmm, is this issue reproducible in a newly-built conda environment with sklearn 0.21.2?

what i do??
from sklearn.cross_validation import train_test_split

ModuleNotFoundError: No module named 'sklearn.cross_validation'

@gulabshah778 which version of TPOT? Maybe updating TPOT will help you solve the issue.

If you are still having issue, please try this. It worked for me.

from sklearn.model_selection import train_test_split

I still getting the error even when I changed the cross_validation by from sklearn.cross_validation import train_test_split

ImportError Traceback (most recent call last)
in
1 #from sklearn.cross_validation import train_test_split
----> 2 from sklearn.model_selection import train_test_split
3 X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=14)
4 #print("There are {} samples in the training dataset".format(X_train.shape[0]))
5 #print("There are {} samples in the testing dataset".format(X_test.shape[0]))

~\Anaconda3\lib\site-packagessklearn\model_selection__init__.py in
17 from ._split import check_cv
18
---> 19 from ._validation import cross_val_score
20 from ._validation import cross_val_predict
21 from ._validation import cross_validate

~\Anaconda3\lib\site-packagessklearn\model_selection_validation.py in
24 from ..utils import (indexable, check_random_state, _safe_indexing,
25 _message_with_time)
---> 26 from ..utils.validation import _check_fit_params
27 from ..utils.validation import _is_arraylike, _num_samples
28 from ..utils.metaestimators import _safe_split

ImportError: cannot import name '_check_fit_params' from 'sklearn.utils.validation'

@EcoHub is the version of scikit-learn > 0.21? If not, please update it. Thank you

Please use:
from sklearn.model_selection import train_test_split

The earlier LOC is not is use:

hi guys,
I have issue on:
pip install sklearn.cross_validation

it has no this module

python: 3.8.6
windows 10

read your comments and not useful, can you help to fix it ?

Was this page helpful?
0 / 5 - 0 ratings