Skip to content

BaggingClassifier.__init__() got an unexpected keyword argument 'base_estimator' #68

Open

Description

@PoojaPrasd

Dear Team,

I am running the titanic demo notebook and getting the below error in the code

skope_rules_clf.fit(X_train, y_train)

in SkopeRules.fit(self, X, y, sample_weight)
265 self._max_depths = self.max_depth
266 if isinstance(self.max_depth, Iterable) else [self.max_depth]
268 for max_depth in self.max_depths:
--> 269 bagging_clf = BaggingClassifier(
270 base_estimator=DecisionTreeClassifier(
271 max_depth=max_depth,
272 max_features=self.max_features,
273 min_samples_split=self.min_samples_split),
274 n_estimators=self.n_estimators,
275 max_samples=self.max_samples
,
276 max_features=self.max_samples_features,
277 bootstrap=self.bootstrap,
278 bootstrap_features=self.bootstrap_features,
279 # oob_score=... XXX may be added
280 # if selection on tree perf needed.
281 # warm_start=... XXX may be added to increase computation perf.
282 n_jobs=self.n_jobs,
283 random_state=self.random_state,
284 verbose=self.verbose)
286 bagging_reg = BaggingRegressor(
287 base_estimator=DecisionTreeRegressor(
288 max_depth=max_depth,
(...)
300 random_state=self.random_state,
301 verbose=self.verbose)
303 clfs.append(bagging_clf)

TypeError: BaggingClassifier.init() got an unexpected keyword argument 'base_estimator'

Activity

  1. Lapsis-glitch commented on Jul 11, 2024

    @Lapsis-glitch

    I ran into the same issue, it seems to stem from sklearn modifying the function parameters.

    This can be fixed if you go into the code and change "base_estimator" to "estimator".

    on linux you can do this with:

    sed -i 's/base_estimator=/estimator=/g' path/to/your/environment/lib/python3.XX/site-packages/skrules/skope_rules.py

  2. liang623589326 commented on Sep 25, 2024

    @liang623589326

    I also encounter with this problem. Can you tell me how to fixed the parameter ("estimator") function or test demo? Thank you very much!

  3. Lapsis-glitch commented on Sep 25, 2024

    @Lapsis-glitch

    I also encounter with this problem. Can you tell me how to fixed the parameter ("estimator") function or test demo? Thank you very much!

    You have to locate the skope_rules.py file in your python environment (the path to it is usually written in the error message you get when trying to run this function).

    Open the file in a text editor of your choice and replace every instance of the base_estimator keyword with estimator and save it. This should then allow the code to run as intended.

  4. liang623589326 commented on Sep 28, 2024

    @liang623589326

    Thank you so much. I've done with you help.

  5. yousseftarhri commented on Jan 29, 2025

    @yousseftarhri

    base_estimator was renamed to estimator in version 1.2 and will be removed in 1.4.

  6. added a commit that references this issue on Feb 16, 2026
    8c4e06b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions