我正在尝试运行 this example从 sklearn 更好地理解他们的 TfidfTransformer 来自 sklearn.feature_extraction.text。但是,我返回了
Traceback (most recent call last):
File "grid_search_text_feature_extraction.py", line 16, in <module>
from sklearn.model_selection import GridSearchCV
ImportError: No module named model_selection
初步搜索后,我发现 model_selection 仅从 0.18 版开始可用。我目前运行的是 0.16.1 版,由于我正在使用的网络配置,我无法自己更新包。来自 iPython (python 2) - ImportError: No module named model_selection我看到 sklearn.model_selection 的前身是 sklearn.cross_validation,但是没有可用的 GridSearchCV。
有什么快速的替代方法可以利用 GridSearchCV 或完全替换它来运行 this example ?
请您参考如下方法:
要查看早期版本的 scikit 示例的版本,只需将 url 中的 stable 替换为您想要的版本,例如: http://scikit-learn.org/0.16/auto_examples/model_selection/grid_search_text_feature_extraction.html#sphx-glr-auto-examples-model-selection-grid-search-text-feature-extraction-py
