ImportError: No module named sklearn.cross_validation

后端 未结 14 1946
天涯浪人
天涯浪人 2020-12-04 08:14

I am using python 2.7 in Ubuntu 14.04. I installed scikit-learn, numpy and matplotlib with these commands:

sudo apt-get install build-essential python-dev p         


        
相关标签:
14条回答
  • 2020-12-04 08:43
    sklearn.cross_validation
    

    has changed to

    sklearn.model_selection
    

    Checkout the documentation here: https://scikit-learn.org/stable/modules/cross_validation.html

    0 讨论(0)
  • 2020-12-04 08:47

    train_test_split is now in model_selection. Just type:

    from sklearn.model_selection import train_test_split
    

    it should work

    0 讨论(0)
  • 2020-12-04 08:47

    change the code like this

    # from sklearn.cross_validation import train_test_split
    from sklearn.model_selection import train_test_split
    
    0 讨论(0)
  • 2020-12-04 08:48

    cross_validation was deprecated some time ago, try switching it out with model_selection

    0 讨论(0)
  • 2020-12-04 08:49

    May be it's due to the deprecation of sklearn.cross_validation. Please replace sklearn.cross_validation with sklearn.model_selection

    Ref- https://github.com/amueller/scipy_2015_sklearn_tutorial/issues/60

    0 讨论(0)
  • 2020-12-04 08:49

    sklearn.cross_validation is now changed to sklearn.model_selection

    Just change

    sklearn.cross_validation
    

    to

    sklearn.model_selection
    
    0 讨论(0)
提交回复
热议问题