2

I am attempting to run this example from sklearn to better understand their TfidfTransformer from sklearn.feature_extraction.text. However, I am returned with

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

After initial searching I see that model_selection is available only beginning with version 0.18. I am currently running version 0.16.1 and am unable to update the package myself due to network config that I am working in. From iPython (python 2) - ImportError: No module named model_selection I see that the predecessor to sklearn.model_selection was sklearn.cross_validation, however there is no GridSearchCV available.

What quick alternative is there to utilize GridSearchCV or replace it completely to run this example?

Community
  • 1
  • 1
sudo_coffee
  • 888
  • 1
  • 12
  • 26
  • 1
    You can access gridsearchCV from sklearn.grid_search in 0.16. See http://scikit-learn.org/0.16/modules/generated/sklearn.grid_search.GridSearchCV.html#sklearn.grid_search.GridSearchCV – Nick Becker Jan 05 '17 at 15:39
  • `Traceback (most recent call last): File "grid_search_text_feature_extraction.py", line 16, in from sklearn.cross_validation import gridsearchCV ImportError: cannot import name gridsearchCV` Looks like `from sklearn.cross_validation import gridsearchCV` does not work? – sudo_coffee Jan 05 '17 at 15:43
  • 1
    I edited my comment. It's in grid_search not cross_validation. That's what I get for answering before double checking the documentation. – Nick Becker Jan 05 '17 at 15:43