Description
If I test either MLPClassifier
or MLPRegressor
with check_estimator
, then there is no issue. However, these neural networks cause StackingClassifier
and StackingRegressor
to fail the estimator check.
Here is the simplest code with which I encounter the issue:
from sklearn.neural_network import MLPClassifier, MLPRegressor
from sklearn.ensemble import StackingClassifier, StackingRegressor
from sklearn.utils.estimator_checks import check_estimator
clf = StackingClassifier(estimators=[('mlp', MLPClassifier())],
final_estimator=MLPClassifier())
check_estimator(clf)
reg = StackingRegressor(estimators=[('mlp', MLPRegressor())],
final_estimator=MLPRegressor())
check_estimator(reg)
Note that the neural networks will cause an issue as either argument, so I used them as both the first and second stacking layers for simplicity.
Within check_estimator
the issue arises when the test check_sample_weights_pandas_series
tries to fit with sample weights:
scikit-learn/sklearn/utils/estimator_checks.py
Lines 790 to 791 in fd23727
Eventually this leads to a TypeError
as fit gets an unexpected keyword sample_weight
from
scikit-learn/sklearn/ensemble/_base.py
Lines 24 to 30 in fd23727
Any solutions?
Versions
Python dependencies:
pip: 20.1.1
setuptools: 47.3.1.post20200616
sklearn: 0.23.1
numpy: 1.17.5
scipy: 1.4.1
Cython: 0.29.20
pandas: 1.0.5
matplotlib: 3.2.1
joblib: 0.15.1
threadpoolctl: 2.1.0
Built with OpenMP: True