Skip to content

Support categorical features from polars. #11565

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

Merged
merged 5 commits into from
Jul 16, 2025

Conversation

trivialfis
Copy link
Member

@trivialfis trivialfis commented Jul 16, 2025

Close #10554
Related: #11088

CPU-only at the moment.

@trivialfis
Copy link
Member Author

cc @rongou

Copy link
Contributor

@Copilot 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 adds support for categorical features from Polars DataFrames in XGBoost. Previously, when using Polars categorical data with XGBoost, a NotImplementedError was raised. Now categorical features are properly handled when enable_categorical=True is set.

Key changes:

  • Implement categorical feature handling for Arrow/Polars data structures
  • Add validation requiring enable_categorical=True for categorical data
  • Refactor Arrow array interface code for better modularity

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
tests/python/test_with_polars.py Updates test to verify categorical feature support with Polars Categorical and Enum types
src/data/adapter.h Adds type validation for offset arrays in categorical data processing
python-package/xgboost/data.py Implements categorical support for Arrow tables and refactors array interface handling
python-package/xgboost/_data_utils.py Moves and enhances Arrow utility functions with categorical data support

@trivialfis trivialfis merged commit 16e3cb5 into dmlc:master Jul 16, 2025
95 of 115 checks passed
@trivialfis trivialfis deleted the cat-polars-1 branch July 16, 2025 22:08
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.

XGBoost Fails with Polars DataFrames Containing Categorical Columns
2 participants