cannot import name ‘cross_validation’ No module named ‘sklearn.learning_curve’ 等问题

  • Post author:
  • Post category:其他



ImportError: cannot import name 'cross_validation'



ModuleNotFoundError: No module named 'sklearn.learning_curve'



ModuleNotFoundError: No module named 'sklearn.grid_search'


在0.18以上的sklearn版本中,以上这些库全部都没掉了,都在model_selection下面

所以以上库都应该该为从sklearn.model_selection导入

代码如下:


from sklearn import cross_validation


改为


from sklearn import model_selection



from sklearn.learning_curve import learning_curve


改为


from sklearn.model_selection import learning_curve



from sklearn.grid_search import GridSearchCV


改为


from sklearn.model_selection import GridSearchCV



版权声明:本文为weixin_39358657原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。