简体   繁体   中英

Command “from sklearn.model_selection import something” runs with a mistake. What should i do?

When I try to run my code I have an error:

ImportError: No module named model_selection

I have my sklearn v.17 installed together with Anaconda. This occurs only if I write "model_selection" after sklearn

from sklearn.model_selection import something

The answer is actually in your question.

The module model_selection has only been introduced in the version 0.18 of sklearn . It does not exist in the version 0.17 .

Look at the history here .

To get the module you thus need to update sklearn . As you use Anconda do (in a terminal):

 conda update scikit-learn

添加到sklearn的答案中,如果要继续使用sklearn版本0.17 ,请尝试以下操作:

from sklearn.cross_validation import train_test_split

我将Anaconda重新安装在默认文件夹中,此故障消失了。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM