ImportError: cannot import name cross_validation

后端 未结 4 1138
没有蜡笔的小新
没有蜡笔的小新 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:46

    This happens because there is no cross_validation object in sklearn. You're likely looking for something more like the cross_validate function. You can access that through

    from sklearn.model_selection import cross_validate
    

    However, you don't need to import any cross-validation software to perform the train-test split, since that will just randomly sample from the data. Try

    from sklearn.model_selection import train_test_split
    

    followed by

    features_train, features_test, labels_train, labels_test = train_test_split(word_data, authors, test_size=0.1, random_state=42)
    

提交回复
热议问题