ImportError: cannot import name cross_validation

后端 未结 4 1125
没有蜡笔的小新
没有蜡笔的小新 2020-12-03 11:50

I cannot import the cross_validation from sklearn library; I use sklearn version 0.20.0

from sklearn import cross_validation

later in the c

4条回答
  •  [愿得一人]
    2020-12-03 12:45

    cross_validation used to exist as a Scikit package*, but was deprecated at some point.

    If you're looking for train_test_split as your code indicates, it's in model_selection:

    from sklearn import model_selection
    
    features_train, features_test, labels_train, labels_test = model_selection.train_test_split(
        word_data, authors, test_size=0.1, random_state=42)
    

    *Looks like this changed in 0.18.

提交回复
热议问题