Skip to content

FIX warning using polars DataFrames in DecisionBoundaryDisplay.from_estimator#28718

Merged
jeremiedbb merged 12 commits into
scikit-learn:mainfrom
patrickkwang:decisionboundaryplot-polars
Apr 10, 2024
Merged

FIX warning using polars DataFrames in DecisionBoundaryDisplay.from_estimator#28718
jeremiedbb merged 12 commits into
scikit-learn:mainfrom
patrickkwang:decisionboundaryplot-polars

Conversation

@patrickkwang

Copy link
Copy Markdown
Contributor

Reference Issues/PRs

Fixes #28717, which is analogous to #23311, but for polars.

See also #25896.

What does this implement/fix? Explain your changes.

This fix is analogous to #23318. We identify when the predictors passed to DecisionBoundaryPlot.from_estimator is a polars DataFrame and refrain from converting it to a numpy array and stripping the column names.

Any other comments?

The way we do this is a bit awkward because we want to avoid importing polars. A nicer way to do this would be something like the following:

X_grid = pl.DataFrame({
    column: series
    for column, series in zip(X.columns, (xx0.ravel(), xx1.ravel()))
})

... but that would require import polars as pl.

Instead we drop the existing columns and add columns with the same names and the data from meshgrid.

@github-actions

github-actions Bot commented Mar 28, 2024

Copy link
Copy Markdown

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit: b66a38d. Link to the linter CI: here

@patrickkwang patrickkwang force-pushed the decisionboundaryplot-polars branch from bcbc83a to b5c5044 Compare March 28, 2024 13:23
@patrickkwang patrickkwang force-pushed the decisionboundaryplot-polars branch from b5c5044 to e729040 Compare March 28, 2024 13:26

@jeremiedbb jeremiedbb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the PR @patrickkwang. ping @glemaitre who made the fix for pandas dataframes for another review.

Comment thread sklearn/inspection/_plot/tests/test_boundary_decision_display.py Outdated
Comment thread sklearn/inspection/_plot/decision_boundary.py Outdated

@jeremiedbb jeremiedbb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please add an entry in the v1.4.rst change log. Otherwise LGTM. Thanks @patrickkwang.

@jeremiedbb jeremiedbb added this to the 1.4.2 milestone Apr 3, 2024
@patrickkwang

Copy link
Copy Markdown
Contributor Author

Please add an entry in the v1.4.rst change log. Otherwise LGTM. Thanks @patrickkwang.

Done.

Comment thread doc/whats_new/v1.4.rst Outdated
@patrickkwang patrickkwang force-pushed the decisionboundaryplot-polars branch from 2306fb0 to 3593d79 Compare April 4, 2024 21:38
@jeremiedbb jeremiedbb modified the milestones: 1.4.2, 1.5 Apr 5, 2024
@jeremiedbb

Copy link
Copy Markdown
Member

We've decided that the 1.4.2 release will only be about numpy 2 support, so I moved the changelog entry into v1.5.rst, which is expected in a month. Sorry for the misleading request.

@glemaitre glemaitre self-requested a review April 9, 2024 15:16

@glemaitre glemaitre left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Otherwise LGTM.

Comment thread sklearn/preprocessing/_function_transformer.py
Comment thread doc/whats_new/v1.5.rst Outdated
@glemaitre glemaitre changed the title Fix warning using polars DataFrames in DecisionBoundaryDisplay.from_estimator FIX warning using polars DataFrames in DecisionBoundaryDisplay.from_estimator Apr 9, 2024
@jeremiedbb

Copy link
Copy Markdown
Member

Thanks @patrickkwang

@jeremiedbb jeremiedbb merged commit 3fa732b into scikit-learn:main Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Warning with DecisionBoundaryPlot and polars DataFrame

4 participants