欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

ModuleNotFoundError: No module named 'sklearn.grid_search'问题的解决

程序员文章站 2022-06-12 22:45:40
...

ModuleNotFoundError: No module named 'sklearn.grid_search'问题的解决

问题描述

python运行代码时,到from sklearn.grid_search import GridSearchCV时报错:

ModuleNotFoundError: No module named 'sklearn.grid_search'

原因

DeprecationWarning: This module was deprecated in version 0.18 in favor of the model_selection module into which all the refactored classes and functions are moved. Also note that the interface of the new CV iterators are different from that of this module. This module will be removed in 0.20.
意思是说:
sklearn.grid_search模块在0.18版本中被弃用,它所支持的类转移到model_selection模块中。还要注意,新的CV迭代器的接口与这个模块的接口不同。sklearn.grid_search将在0.20中被删除。

解决办法

检查Scikit-Learn的版本conda list scikit-learn如果高于0.20说明是版本问题。
from sklearn.grid_search import GridSearchCV改为from sklearn.model_selection import GridSearchCV

相关标签: sklearn