module 'sklearn' has no attribute 'cross_validation'

后端 未结 5 919
-上瘾入骨i
-上瘾入骨i 2021-02-06 22:11

I am trying to split my dataset into training and testing dataset, but I am getting this error:

X_train,X_test,Y_train,Y_test = sklearn.cross_validation.train_te         


        
相关标签:
5条回答
  • 2021-02-06 22:17

    Try this:

    from sklearn.model_selection import train_test_split
    X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size=0.33, random_state=101)
    
    0 讨论(0)
  • 2021-02-06 22:18

    you can try this

    X_train,X_test,Y_train,Y_test = 
        sklearn.model_selection.train_test_split(X,boston_df.price)
    
    0 讨论(0)
  • 2021-02-06 22:22

    sklearn does not automatically import its subpackages. If you only imported via: import sklearn, then it wont work. Import with import sklearn.cross_validation instead.

    Furhter, sklearn.cross_validation will be deprecated in version 0.20. Use sklearn.model_selection.train_test_split instead.

    0 讨论(0)
  • 2021-02-06 22:26

    "cross_validation" name is now deprecated and was replaced by "model_selection" inside the new anaconda versions. So you can use

    from sklearn.model_selection import train_test_split
    
    0 讨论(0)
  • 2021-02-06 22:39

    The equivalent to cross_validation in sklearn is:

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