当前位置:   article > 正文

【Bug记录】ModuleNotFoundError: No module named ‘sklearn.grid_search‘_sklearn.grid_search找不到

sklearn.grid_search找不到


一、报错代码

from sklearn.grid_search import GridSearchCV
  • 1

二、报错信息

ModuleNotFoundError                       Traceback (most recent call last)
Input In [28], in <cell line: 8>()
      6 from IPython.display import Image
      7 from sklearn.ensemble import RandomForestRegressor
----> 8 from sklearn.grid_search import GridSearchCV
      9 # from sklearn.model_selection import GridSearchCV
     10 from sklearn.model_selection import train_test_split

ModuleNotFoundError: No module named 'sklearn.grid_search'
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

三、报错原因

sklearn.grid_search模块在0.18版本中被弃用,它所支持的类转移到model_selection模块中。还要注意,新的CV迭代器的接口与这个模块的接口不同。sklearn.grid_search将在0.20中被删除。

四、解决方案

将报错代码替换为下面的代码即可解决问题:

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

闽ICP备14008679号