Skip to content

Enable categorical feature support by default.#12015

Open
trivialfis wants to merge 9 commits intodmlc:masterfrom
trivialfis:cat-default
Open

Enable categorical feature support by default.#12015
trivialfis wants to merge 9 commits intodmlc:masterfrom
trivialfis:cat-default

Conversation

@trivialfis
Copy link
Member

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.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_categorical from False to True in core DMatrix classes and sklearn estimators
  • Removed explicit enable_categorical=True from 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.

@trivialfis
Copy link
Member Author

I don't know how to fix the pylint error without major refactoring.

@RAMitchell
Copy link
Member

@trivialfis let me have a go in another PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove enable_categorical parameter by making it True as default.

2 participants

Comments