I am doing an image detection problem but, I got some errors while I import RandomizedSearchCV
.
I have installed:
pip3 install scikit-learn
pip3 install scikit-image
I tried this code first:
from sklearn.neighbors import KNeighborsClassifier
from sklearn.model_selection import GridSearchCV
its worked, After that, I import RandomizedSearchCV
like this, and its showing error.
from sklearn.grid_search import RandomizedSearchCV
from sklearn.grid_search import GridSearchCV
from sklaern.cross_validation import train_test_split
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-11-9f5ecfd22091> in <module>
----> 1 from sklearn.grid_search import RandomizedSearchCV
2 from sklearn.grid_search import GridSearchCV
3 from sklaern.cross_validation import train_test_split
ModuleNotFoundError: No module named 'sklearn.grid_search'
>>> import sklearn
>>> sklearn.__version__
'0.20.3'
In recent versions, these modules are now under sklearn.model_selection
, and not any more under sklearn.grid_search
, and the same holds true for train_test_split
(docs); so, you should change your imports to:
from sklearn.model_selection import RandomizedSearchCV
from sklearn.model_selection import GridSearchCV
from sklearn.model_selection import train_test_split
or more concisely
from sklearn.model_selection import RandomizedSearchCV, GridSearchCV, train_test_split
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With