Thanks to visit codestin.com
Credit goes to github.com

Skip to content

AttributeError: 'super' object has no attribute '__sklearn_tags__' #30542

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

Closed
LiorxCohen opened this issue Dec 26, 2024 · 13 comments
Closed

AttributeError: 'super' object has no attribute '__sklearn_tags__' #30542

LiorxCohen opened this issue Dec 26, 2024 · 13 comments
Labels

Comments

@LiorxCohen
Copy link

LiorxCohen commented Dec 26, 2024

Describe the bug

AttributeError                            Traceback (most recent call last)
[/usr/local/lib/python3.10/dist-packages/IPython/core/formatters.py](https://localhost:8080/#) in __call__(self, obj, include, exclude)
    968 
    969             if method is not None:
--> 970                 return method(include=include, exclude=exclude)
    971             return None
    972         else:

4 frames
[/usr/local/lib/python3.10/dist-packages/sklearn/base.py](https://localhost:8080/#) in __sklearn_tags__(self)
    538 
    539     def __sklearn_tags__(self):
--> 540         tags = super().__sklearn_tags__()
    541         tags.estimator_type = "classifier"
    542         tags.classifier_tags = ClassifierTags()

AttributeError: 'super' object has no attribute '__sklearn_tags__'

Steps/Code to Reproduce

.

Expected Results

Working XGBClassifier model

Actual Results

None

Versions

1.6
@LiorxCohen LiorxCohen added Bug Needs Triage Issue requires triage labels Dec 26, 2024
@LiorxCohen
Copy link
Author

#XGBoost Classification model
from xgboost import XGBClassifier

instantiate the model

xgb = XGBClassifier(learning_rate=0.4,max_depth=7, method='logloss')
#fit the model
xgb.fit(X_train, y_train)

@zyrusvito
Copy link

Did you fix this error? If yes, can you tell me how?

@glemaitre
Copy link
Member

Related to the issue here: #30479

Should be resolved in: #30516

@glemaitre
Copy link
Member

Since this is with XGBoost, it has been resolved in: dmlc/xgboost#11021
So it will be available in their next release.

@LiorxCohen
Copy link
Author

Since this is with XGBoost, it has been resolved in: dmlc/xgboost#11021 So it will be available in their next release.

thanks, do you know when this version gonna be published?

@jeremiedbb jeremiedbb removed the Needs Triage Issue requires triage label Dec 31, 2024
@fingoldo
Copy link

fingoldo commented Jan 1, 2025

Hopefully in future, when adding such breaking releases, some fallback mechanics will be considered by core devs. This sklearn_tags thing has totally broken xgboost python objects usage.

ChanderG added a commit to foundation-model-stack/fm-training-estimator that referenced this issue Jan 13, 2025
bug in 1.6: scikit-learn/scikit-learn#30542
we need the next release of xgboost (> 2.1.3), which is not out yet
@timotta
Copy link

timotta commented Jan 15, 2025

I could solved locally only fixing the version of scikit-learn to 1.5.2

@SrBliss
Copy link

SrBliss commented Jan 28, 2025

Is there an updated date for releasing the fix?

@betatim
Copy link
Member

betatim commented Jan 28, 2025

This is not a bug, but a change in scikit-learn 1.6. The way the tag infrastructure works has been modernised. In particular we are trying to move towards having an official developer API. For example tags were something that was considered internal, but in reality was used by third party estimators. There was no great way of getting on the path of improvement without the changes in 1.6. So apologies for the pain, but hopefully it is worth it in the long term.

TL;DR: your estimator class has to inherit from the base estimator in scikit-learn.

You don't have to inherit from the base estimator, but in that case you need to provide a lot of infrastructure yourself. In this case the __sklearn_tags__. So we recommend you use the base estimator unless you are a big project that has the resources to keep your own implementation in sync.

Some more details, advice and explanation is in https://blog.scikit-learn.org/updates/dev-api/

There is also a new library that helps make it easier for third party libraries to be compatible with multiple versions of scikit-learn, sklearn-compat. It contains a helper for this case https://github.com/sklearn-compat/sklearn-compat?tab=readme-ov-file#tags-__sklearn_tags__-and-estimator-tags

@bhavikdataslush
Copy link

I installed version 1.3.2 and it is working for me

@dipaksah20
Copy link

I tried with version 1.3.2 , it is not working for me

@Yoannoza
Copy link

version 1.3.2 doesn't work for me also

@ygbingo
Copy link

ygbingo commented Feb 13, 2025

1.5.2 is ok !!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests