hyperopt / hyperopt-sklearn

Hyper-parameter optimization for sklearn
hyperopt.github.io/hyperopt-sklearn
Other
1.59k stars 272 forks source link

AttributeError: module 'sklearn' has no attribute 'preprocessing' #134

Open moongraber opened 5 years ago

moongraber commented 5 years ago

Hi

I am using windows 10 sklearn 0.21.1 and hyperopt 0.2

I do : `estim = HyperoptEstimator(classifier=any_regressor('my_clf'), preprocessing=any_preprocessing('my_pre'), algo=tpe.suggest, max_evals=100, trial_timeout=120)

estim.fit(train_x, train_y) ` get error:

File "d:\python git\hyperopt-sklearn\hpsklearn\components.py", line 166, in sklearn_StandardScaler return sklearn.preprocessing.StandardScaler(*args, **kwargs)

AttributeError: module 'sklearn' has no attribute 'preprocessing'

but I have no problem doing `import sklearn.preprocessing

from sklearn.preprocessing import StandardScaler `

bjkomer commented 5 years ago

hmm, that's really odd. Does the issue still happen with hyperopt-sklearn version 0.3? It is best to install the version from github, the one on pypi is quite old now.

pip install git+https://github.com/hyperopt/hyperopt-sklearn.git
MikeB2012 commented 3 years ago

I had this exactly the same issue arise in a previously working notebook. I opened up a notebook I had used successfully a month ago and it error-ed out exactly as for the OP. If I used the same workaround it worked again. My installed version of scikit-learn is 0.24.1.

alexjmartin commented 1 year ago

I found this issue with version 0.24.2 - resolved by also adding the explicit import "from sklearn import preprocessing". Similarly I did not need this line previously when running notebooks on an earlier version of sklearn but hopefully this also works for others!

rimshakhan-yash commented 1 year ago

AttributeError: module 'sklearn.preprocessing' has no attribute 'preprocessing'