赞
踩
目录
ModuleNotFoundError: No module named 'sklearn.cross_validation'
我的代码
- # Split data into training and testing sets
- from sklearn.metrics import accuracy_score, fbeta_score, roc_curve, auc, roc_auc_score
- from sklearn.cross_validation import train_test_split
-
-
- X_train_ADA, X_test_ADA, y_train_ADA, y_test_ADA = train_test_split(features_ADA, popular_label, test_size = 0.1, random_state = 0)
-
- X_train_LR, X_test_LR, y_train_LR, y_test_LR = train_test_split(features_LR, popular_label, test_size = 0.1, random_state = 0)
-
- X_train_RF, X_test_RF, y_train_RF, y_test_RF = train_test_split(features_RF, popular_label, test_size = 0.1, random_state = 0)
-
- print("Training set has {} samples.".format(X_train_ADA.shape[0]))
- print("Testing set has {} samples.".format(X_test_ADA.shape[0]))
因为当版本升级后,函数的用法或者属性有所改变。
新版本的sklearn没有这个模块,所以需要用另一个模块代替。
将代码
from sklearn.cross_validation import train_test_split
改为
from sklearn.model_selection import train_test_split
引用:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。