Enable categorical feature support by default.#12015
Open
trivialfis wants to merge 9 commits intodmlc:masterfrom
Open
Enable categorical feature support by default.#12015trivialfis wants to merge 9 commits intodmlc:masterfrom
trivialfis wants to merge 9 commits intodmlc:masterfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR enables categorical feature support by default in XGBoost by changing the default value of the enable_categorical parameter from False to True. This aligns with the goal stated in issue #12014 to make categorical support the default behavior while maintaining backward compatibility by keeping the parameter available for users who wish to disable it.
Changes:
- Changed default value of
enable_categoricalfromFalsetoTruein core DMatrix classes and sklearn estimators - Removed explicit
enable_categorical=Truefrom test code throughout the codebase - Removed redundant Python-side validation for categorical features with exact tree method (now handled in C++)
- Applied code formatting improvements including import ordering standardization
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| python-package/xgboost/core.py | Changed default value of enable_categorical to True in DMatrix, QuantileDMatrix, and ExtMemQuantileDMatrix classes; improved docstring formatting |
| python-package/xgboost/sklearn.py | Changed default value of enable_categorical to True in sklearn estimator base class; removed redundant validation logic for exact tree method with categorical features; improved docstring formatting |
| tests/test_distributed/test_with_dask/test_with_dask.py | Removed explicit enable_categorical=True from DaskDMatrix and DaskXGBRegressor instantiations; improved import ordering |
| tests/test_distributed/test_gpu_with_dask/test_gpu_with_dask.py | Removed explicit enable_categorical=True from DaskQuantileDMatrix instantiations; improved import ordering |
| tests/python/test_with_sklearn.py | Removed explicit enable_categorical=True from XGBRegressor instantiations; applied extensive code formatting improvements including quote normalization and line breaking |
| tests/python/test_with_polars.py | Removed explicit enable_categorical=True from DMatrix and QuantileDMatrix instantiations; removed test checking for error when enable_categorical not set; improved import ordering |
| tests/python/test_with_pandas.py | Removed explicit enable_categorical=True from DMatrix instantiations; removed test checking for error when enable_categorical not set; improved import ordering |
| tests/python/test_quantile_dmatrix.py | Removed explicit enable_categorical=True from XGBRegressor, DMatrix, and QuantileDMatrix instantiations; improved import ordering |
| tests/python/test_predict.py | Removed explicit enable_categorical=True from DMatrix instantiation; improved import ordering |
| tests/python/test_model_io.py | Removed explicit enable_categorical=True from DMatrix instantiation; improved code formatting |
| tests/python/test_demos.py | Removed explicit enable_categorical=True from XGBRegressor instantiation |
| tests/python/test_data_iterator.py | Removed explicit enable_categorical=True from DMatrix and QuantileDMatrix instantiations; improved import ordering |
| tests/python/generate_models.py | Removed explicit enable_categorical=True from DMatrix, XGBRegressor, and QuantileDMatrix instantiations; improved import ordering |
| tests/python-gpu/test_gpu_with_sklearn.py | Removed explicit enable_categorical=True from XGBClassifier and XGBRegressor instantiations; improved import ordering |
| tests/python-gpu/test_gpu_prediction.py | Removed explicit enable_categorical=True from DMatrix instantiations; improved import ordering |
| tests/python-gpu/test_gpu_ordinal.py | Removed explicit enable_categorical=True from DMatrix instantiations; improved import ordering |
| tests/python-gpu/test_from_cudf.py | Removed explicit enable_categorical=True from DMatrix and QuantileDMatrix instantiations; removed tests checking for error when enable_categorical not set; improved import ordering |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
RAMitchell
approved these changes
Feb 15, 2026
Member
Author
|
I don't know how to fix the pylint error without major refactoring. |
Member
|
@trivialfis let me have a go in another PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
close #12014
I kept the XGBoost parameter to avoid a breaking change to the API, and users can still disable categorical feature support if they wish.