ModuleNotFoundError: No module named 'sklearn.grid_search'问题的解决
程序员文章站
2022-06-12 22:45:40
...
问题描述
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
推荐阅读
-
下载python中Crypto库报错:ModuleNotFoundError: No module named ‘Crypto’的解决
-
解决Python找不到ssl模块问题 No module named _ssl的方法
-
python提示No module named images的解决方法
-
解决Python源码编译时提示:ModuleNotFoundError: No module named ‘distutils.command‘
-
巨坑总结:ModuleNotFoundError: No module named ‘tools‘引发的一系列问题
-
下载python中Crypto库报错:ModuleNotFoundError: No module named ‘Crypto’的解决
-
解决python "No module named pip"的问题
-
解决Python找不到ssl模块问题 No module named _ssl的方法
-
PyCharm出现module'matplotlib'hasnoattribute'verbose问题的解决方法
-
解决方法:在Python中使用Win32api报错的问题,No module named win32api