8000 [BUG] AttributeError in RotationForest when using base_estimator parameter · Issue #8265 · sktime/sktime · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[BUG] AttributeError in RotationForest when using base_estimator parameter #8265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
msicilia opened this issue May 18, 2025 · 1 comment · May be fixed by #8270
Open

[BUG] AttributeError in RotationForest when using base_estimator parameter #8265

msicilia opened this issue May 18, 2025 · 1 comment · May be fixed by #8270
Labels
bug Something isn't working module:classification classification module: time series classification

Comments

@msicilia
Copy link

Describe the bug

In RotationForest, using the parameter base_estimator causes AttributeError when calling fit().

To Reproduce
Here is a minimal example

from sktime.classification.sklearn import RotationForest
from sklearn.tree import DecisionTreeClassifier
cls = RotationForest(base_estimator=DecisionTreeClassifier())
X = [
    [1, 2, 3],
    [4, 5, 6],
    [7, 8, 9],
]
y = [0, 1, 0]
cls.fit(X, y)

This produces:

...
  File "/.../sktime/classification/sklearn/_rotation_forest.py", line 436, in _fit_estimator
    tree = _clone_estimator(self._base_estimator, random_state=rs)
                            ^^^^^^^^^^^^^^^^^^^^
AttributeError: 'RotationForest' object has no attribute '_base_estimator'. Did you mean: 'base_estimator'?

Expected behavior
Correctly fitting the classifier.

Additional context

Looking at the source code of RotationForest, in __init__ the parameter is correctly captured:

...
 self.base_estimator = base_estimator

But in the code of fit() one can see this code fragment:

... 
if self.base_estimator is None:
       self._base_estimator = DecisionTreeClassifier(criterion="entropy")

This correctly instantiates the internal _base_estimator for the case of the default parameter. But in the case a custom estimator was passed at instantiation, it seem that internal is not created. And then when calling _clone_estimator the exception in the error message above is thrown.

Versions

System: python: 3.12.0 (main, Oct 2 2023, 20:56:14) [Clang 16.0.3 ] executable: /.../.venv/bin/python3 machine: macOS-15.4.1-arm64-arm-64bit Python dependencies: pip: None sktime: 0.37.0 sklearn: 1.5.0 skbase: 0.12.2 numpy: 1.26.4 scipy: 1.15.3 pandas: 2.2.3 matplotlib: 3.10.3 joblib: 1.4.2 numba: 0.61.2 statsmodels: None pmdarima: None statsforecast: None tsfresh: None tslearn: None torch: 2.3.1 tensorflow: None
@msicilia msicilia added the bug Something isn't working label May 18, 2025
@github-project-automation github-project-automation bot moved this to Needs triage & validation in Bugfixing May 18, 2025
@fkiraly fkiraly linked a pull request May 20, 2025 that will close this issue
@fkiraly fkiraly added the module:classification classification module: time series classification label May 20, 2025
@fkiraly
Copy link
Collaborator
fkiraly commented May 20, 2025

Thanks for reporting - fix in #8270.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working module:classification classification module: time series classification
Projects
Status: Needs triage & validation
Development

Successfully merging a pull request may close this issue.

2 participants
0