scikit-learnのStackingClassifierでKerasClassifierを使った時に表題のエラー。
ValueError: The estimator KerasClassifier should be a classifier.
sklearnのモデルには、classifierやregressorなどを指定する属性として_estimator_typeを持っている。
This distinction between classifiers and regressors is implemented using the
https://scikit-learn.org/stable/developers/develop.html_estimator_type
attribute, which takes a string value. It should be"classifier"
for classifiers and"regressor"
for regressors and"clusterer"
for clustering methods, to work as expected.
そのため、KerasClassifierに対して明示的にclassifierであることを示せばOK。
nn = KerasClassifier()
nn._estimator_type = "classifier"
参考
Developing scikit-learn estimators
Whether you are proposing an estimator for inclusion in scikit-learn, developing a separate package compatible with scik...
The estimator KerasClassifier should be a classifier. · Issue #13669 · keras-team/keras
Please make sure that this is a Bug or a Feature Request and provide all applicable information asked by the template. I...
コメント