Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No module named model_selection?how fix it? #314

Closed
MrLevo520 opened this issue Nov 13, 2016 · 28 comments
Closed

No module named model_selection?how fix it? #314

MrLevo520 opened this issue Nov 13, 2016 · 28 comments
Labels

Comments

@MrLevo520
Copy link

"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"

@sam2015
Copy link

sam2015 commented Nov 13, 2016

+1

@weixuanfu
Copy link
Contributor

weixuanfu commented Nov 14, 2016

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.

@rhiever
Copy link
Contributor

rhiever commented Nov 15, 2016

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.

@rhiever
Copy link
Contributor

rhiever commented Nov 17, 2016

@MrLevo520, did this solve your issue?

@benjamingregory
Copy link

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

@rhiever rhiever closed this as completed Dec 5, 2016
@copernico
Copy link

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

@rhiever
Copy link
Contributor

rhiever commented Mar 8, 2017

Edited my comment above.

@ps2802
Copy link

ps2802 commented Jul 3, 2017

@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

`

@rhiever
Copy link
Contributor

rhiever commented Jul 7, 2017

Did you try conda update sklearn?

@gnishad9573
Copy link

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'

@Rootmannii
Copy link

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

@rhiever
Copy link
Contributor

rhiever commented Aug 9, 2018 via email

@cakmakaf
Copy link

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"

@vaibhavagarwa
Copy link

@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.

@weixuanfu
Copy link
Contributor

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

@Birmilyarkirpi
Copy link

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

@mhrihab
Copy link

mhrihab commented Jul 11, 2019

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

@Saurav6789
Copy link

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

@JoeyAlvizo
Copy link

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

@weixuanfu
Copy link
Contributor

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

@gulabshah778
Copy link

what i do??
from sklearn.cross_validation import train_test_split

ModuleNotFoundError: No module named 'sklearn.cross_validation'

@weixuanfu
Copy link
Contributor

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

@ilanalini
Copy link

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

from sklearn.model_selection import train_test_split

@EcoHub
Copy link

EcoHub commented Feb 29, 2020

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-packages\sklearn\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-packages\sklearn\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'

@weixuanfu
Copy link
Contributor

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

@ChandraSekharMukhopadhyay

Please use:
from sklearn.model_selection import train_test_split

The earlier LOC is not is use:

@andrianamin
Copy link

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 ?

@swaranlata-99
Copy link

how can solve it. i m stuck here.
import sklearn
print(sklearn.version)
0.23.2

from sklearn.model_selection import train_test_split
ImportError Traceback (most recent call last)
in
----> 1 from sklearn.model_selection import train_test_split

~\anaconda3\lib\site-packages\sklearn\model_selection_init_.py in
19 from ._split import check_cv
20
---> 21 from ._validation import cross_val_score
22 from ._validation import cross_val_predict
23 from ._validation import cross_validate

~\anaconda3\lib\site-packages\sklearn\model_selection_validation.py in
26 from ..utils.validation import _num_samples
27 from ..utils.validation import _deprecate_positional_args
---> 28 from ..utils.fixes import delayed
29 from ..utils.metaestimators import _safe_split
30 from ..metrics import check_scoring

ImportError: cannot import name 'delayed' from 'sklearn.utils.fixes' (C:\Users\hp\anaconda3\lib\site-packages\sklearn\utils\fixes.py)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests