32

I am encountering an AttributeError while fitting an XGBRegressor using RandomizedSearchCV from Scikit-learn. The error message states:

'super' object has no attribute '__sklearn_tags__'.

This occurs when I invoke the fit method on the RandomizedSearchCV object. I suspect it could be related to compatibility issues between Scikit-learn and XGBoost or Python version. I am using Python 3.12, and both Scikit-learn and XGBoost are installed with their latest versions.

I attempted to tune the hyperparameters of an XGBRegressor using RandomizedSearchCV from Scikit-learn. I expected the model to fit the training data without issues and provide the best parameters after cross-validation.

I also checked for compatibility issues, ensured the libraries were up-to-date, and reinstalled Scikit-learn and XGBoost, but the error persists.

1

4 Answers 4

33

Scikit-learn version 1.6.0 modified the API around its "tags", and that's the cause of this error. XGBoost made the necessary changes in version 2.1.4 (specifically in PR11021). In sklearn 1.6.1, the error was downgraded to a warning (to be returned to an error in 1.7). So you should be OK with any of:

  1. xgboost >=2.1.4
  2. sklearn >=1.6.1,<1.7, and expect DeprecationWarnings
  3. sklearn <1.6

See also sklearn Issue#30479 and 1.6.1 release notes, and xgboost 2.1.4 release notes.

Sign up to request clarification or add additional context in comments.

8 Comments

thanks for this ,the downgraded 1.5.2 is working
As of February 2025, this issue has been fixed with xgboost's 2.1.4 release: github.com/dmlc/xgboost/releases/tag/v2.1.4
Unsure this is correct. I have sklearn 1.6.1 AND get this error.
@Sven, post that as a new question with some details? (And link from here?)
Did no one at sklearn test this?? The issue linked makes it sound like inheriting from Mixins is wrong?
|
16

I also had a similiar error,Xg boost too. But what the guy above me said, uninstall and reinstalling a lower version of sklearn (i used version 1.5.2) fixed this issue for me!

!pip uninstall -y scikit-learn
!pip install scikit-learn==1.5.2

Comments

10

Scikit-learn version 1.5.2 does not solve the problem. Try downgrading further. What worked for me was 1.3.1.

1 Comment

This is correct - 1.3.1 works for me - downgraded from 1.6.1.
0

i have faced same issue with sklearn and scikeras, i changed hyper parameter tunning method with keras_tuner library.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.