替代 sklearn.model_selection 导入 GridSearchCV

Alternative to sklearn.model_selection import GridSearchCV

我正在尝试 运行 this example 来自 sklearn 以更好地理解他们来自 sklearn.feature_extraction.textTfidfTransformer。但是,我返回

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 版开始可用。我目前使用的是 运行ning 版本 0.16.1,由于我正在使用的网络配置,我无法自己更新软件包。从 我看到 sklearn.model_selection 的前身是 sklearn.cross_validation,但是没有可用的 GridSearchCV。

有什么快速的替代方法可以利用 GridSearchCV 或将其完全替换为 运行 this example?

您的示例来自 url:http://scikit-learn.org/stable/auto_examples/model_selection/grid_search_text_feature_extraction.html#sphx-glr-auto-examples-model-selection-grid-search-text-feature-extraction-py

要查看早期版本的 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