Windows 10, python3.6版本,在执行from sklearn.cross_validation import cross_val_score时报错误信息:ModuleNotFoundError: No module named ‘sklearn.cross_validation’,具体如下:
ModuleNotFoundError Traceback (most recent call last)
in ()
8 from sklearn.decomposition import PCA
9 from sklearn.preprocessing import LabelEncoder, LabelBinarizer
—> 10 from sklearn.cross_validation import cross_val_score
11
12 from scipy import stats
ModuleNotFoundError: No module named 'sklearn.cross_validation
经查看,我当前scikit-learn版本号为0.21.3,在该版本中cross_validation 已经被遗弃,而应该改用model_selection,因此上面这条语句做如下更改即可。
from sklearn.model_selection import cross_val_score
快来试试吧!-