BalancedBaggingClassifier

As it si asked I import the BalancedBaggingClassifier, use HistGradientBoostingClassifier as a base_estimator and fix the hyperparameter n_estimators to 50, the code is:

from imblearn.ensemble import BalancedBaggingClassifier

balanc_bagclas = BalancedBaggingClassifier(
  base_estimator_=HistGradientBoostingClassifier, n_estimators=50
)
cv_results = cross_validate(
    balanc_bagclas, data, target, cv=10, scoring="balanced_accuracy", n_jobs=2,
    return_estimator=True,
)
cv_results["test_score"].mean()

but I get:

TypeError: __init__() got an unexpected keyword argument 'base_estimator_'

Can you help me? thanks

Hi, the parameter is called “base_estimator” not " base_estimator_"

Thank you, I have obtained “nan” as a response?, do you think I have to manage unknown data?, Can you help me, the excercise only say fix the hyperparameter n_estimators to 50. Thank you.

There is a () missing after HistGradientBoostingClassifier,
and within () you need to specify the parameters max_iter and early_stopping for this classifier.

balanc_bagclas = BalancedBaggingClassifier(HistGradientBoostingClassifier(max_iter=?, early_stopping=?), n_estimators=50)

In addition, @ldziej be aware that you can debug your code by looking at the traceback of the error. It easier to set error_score="raise" to get a single traceback instead of the warning in cross_validate.