Skip to content
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

fix: Improve hist binning around breakpoints #20054

Merged
merged 1 commit into from
Nov 28, 2024

Conversation

lukemanley
Copy link
Contributor

Improves binning accuracy around breakpoints. Also seems to be 20-30% faster.

import polars as pl

pl.Series([1, 2, 3, 4]).hist(bin_count=3)

# main:

# ┌────────────┬──────────────┬───────┐
# │ breakpoint ┆ category     ┆ count │
# │ ---        ┆ ---          ┆ ---   │
# │ f64        ┆ cat          ┆ u32   │
# ╞════════════╪══════════════╪═══════╡
# │ 2.0        ┆ (0.997, 2.0] ┆ 1     │
# │ 3.0        ┆ (2.0, 3.0]   ┆ 1     │
# │ 4.0        ┆ (3.0, 4.0]   ┆ 2     │
# └────────────┴──────────────┴───────┘

# PR:

# ┌────────────┬──────────────┬───────┐
# │ breakpoint ┆ category     ┆ count │
# │ ---        ┆ ---          ┆ ---   │
# │ f64        ┆ cat          ┆ u32   │
# ╞════════════╪══════════════╪═══════╡
# │ 2.0        ┆ (0.997, 2.0] ┆ 2     │
# │ 3.0        ┆ (2.0, 3.0]   ┆ 1     │
# │ 4.0        ┆ (3.0, 4.0]   ┆ 1     │
# └────────────┴──────────────┴───────┘

@github-actions github-actions bot added fix Bug fix python Related to Python Polars rust Related to Rust Polars labels Nov 28, 2024
@ritchie46
Copy link
Member

Nice!

@ritchie46 ritchie46 merged commit 9513c52 into pola-rs:main Nov 28, 2024
24 of 25 checks passed
@lukemanley lukemanley deleted the hist-breakpoint-accuracy branch December 6, 2024 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Bug fix python Related to Python Polars rust Related to Rust Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants