简体   繁体   中英

ImportError: cannot import name model_selection

I am trying to learn data analysis using the iris data set. So I just am copying the already written code for this subject and I get the following error regarding the libraries :

Traceback (most recent call last):
  File "iris.py", line 6, in <module>
    from sklearn import model_selection
ImportError: cannot import name model_selection

And here is how I import this module: from sklearn import model_selection

I am using python 2.7, What could be the problem? I suspect there might be a problem with the version!right?or not?

Please don't suggest Anaconda, I am not willing to use it.

Thanks a bunch

sklearn.model_selection is available for version 0.18 or late version

Please update your sklearn by pip or other tools 

org website http://scikit-learn.org/stable/whats_new.html#version-0-18

Version 0.18

September 28, 2016 Last release with Python 2.6 support Scikit-learn 0.18 will be the last version of scikit-learn to support Python 2.6. Later versions of scikit-learn will require Python 2.7 or above. Model Selection Enhancements and API Changes

The model_selection module The new module sklearn.model_selection, which groups together the functionalities of formerly sklearn.cross_validation, sklearn.grid_search and sklearn.learning_curve, introduces new possibilities such as nested cross-validation and better manipulation of parameter searches with Pandas. Many things will stay the same but there are some key differences. Read below to know more about the changes. Data-independent CV splitters enabling nested cross-validation

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