pythonmachine-learningscikit-learnxgboost

'super' object has no attribute '__sklearn_tags__'


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.


Solution

  • 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.