当前位置:   article > 正文

ModuleNotFoundError: No module named ‘sklearn.cross_validation‘_modulenotfounderror: no module named 'sklearn.cros

modulenotfounderror: no module named 'sklearn.cross_validation

目录

问题描述

问题原理

问题解决


问题描述

ModuleNotFoundError: No module named 'sklearn.cross_validation'

我的代码

  1. # Split data into training and testing sets
  2. from sklearn.metrics import accuracy_score, fbeta_score, roc_curve, auc, roc_auc_score
  3. from sklearn.cross_validation import train_test_split
  4. 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)
  5. 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)
  6. 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)
  7. print("Training set has {} samples.".format(X_train_ADA.shape[0]))
  8. 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

 引用:

ModuleNotFoundError: No module named ‘sklearn.cross_validation‘ - 知乎问题描述ModuleNotFoundError: No module named 'sklearn.cross_validation' 我的代码 # Split data into training and testing sets from sklearn.metrics import accuracy_score, fbeta_score, roc_curv…https://zhuanlan.zhihu.com/p/511132273

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/308061
推荐阅读
相关标签
  

闽ICP备14008679号