pickbuckets
Bucketing rules you can serialize, inspect, diff, and run anywhere.
pickbuckets turns raw numerical and categorical values into human-readable,
versioned bucketing rules. Fit a rule with the full stack (pandas, Polars,
scikit-learn), serialize it to JSON, and apply it in a plain-Python service with
no runtime dependencies. The same rule produces identical results in
training, batch scoring, online inference, and monitoring.
Portability in one example
Fit where the data lives; apply where the data doesn't.
# --- training environment (full stack available) ---
from pickbuckets import EqualFrequencyBucket
bucket = EqualFrequencyBucket(n_bins=4, duplicates="drop").fit(training_values)
payload = bucket.to_json() # store this string anywhere
# --- serving environment (standard library only) ---
from pickbuckets import Rule
from pickbuckets.runtime import apply_rule
rule = Rule.from_json(payload)
codes = apply_rule(rule, [0, 5, 10, None]) # no pandas / Polars / sklearn
apply_rule is pure Python (optionally NumPy) and is verified by a CI job with
pandas, Polars, and scikit-learn uninstalled.
Install
python -m pip install pickbuckets # dependency-free core
python -m pip install "pickbuckets[pandas]"
python -m pip install "pickbuckets[polars]" # Python 3.10+
python -m pip install "pickbuckets[sklearn]"
python -m pip install "pickbuckets[plot]"
python -m pip install "pickbuckets[all]"
python -m pip install -e ".[dev,all]" # development
Bucketers
Every bucketer fits to a single unified Rule and shares
the same fit / transform / summary / to_json shape. transform() uses
only the saved rule — never the training data.
| Bucketer | Kind | What it does | Needs |
|---|---|---|---|
EqualWidthBucket |
numeric | Equal-width bins from min/max | core |
EqualFrequencyBucket |
numeric | Quantile (equal-frequency) bins | core |
CustomBoundaryBucket |
numeric | Manual, validated edges (supports ±inf) |
core |
RareCategoryBucket |
categorical | Fold rare/unseen categories to a fallback | core |
AutoBucket |
mixed | One rule per column, dtype-driven dispatch | core |
WoEBucket |
supervised | WoE/IV with monotonic + min-bin-size constraints | core |
ChiMergeBucket |
supervised | Chi-square adjacent-bin merging | core |
DecisionTreeBucket |
supervised | Edges from a shallow decision tree | [sklearn] |
ExternalSplitBucket |
numeric | Import external splits (e.g. OptBinning) | core |
StreamingEqualFrequencyBucket |
numeric, experimental | Online/approximate quantile bins for out-of-core data | core |
Plotting helpers (pickbuckets.plotting, behind [plot]) return matplotlib
Axes for bucket counts, target rate, and WoE.
from pickbuckets import AutoBucket, EqualWidthBucket
frame = {"age": [18, 25, 34, 52, 70], "country": ["FR", "FR", "US", "DE", "DE"]}
auto = AutoBucket(
n_bins=3,
min_frequency=2,
overrides={"age": EqualWidthBucket(n_bins=3, labels="interval")},
).fit(frame)
print(auto.transform(frame))
Configurable, serializable policies cover missing values
(separate / most_frequent / propagate / error), numeric boundaries
(clip / underflow_overflow / error), and unknown categories
(other / missing / keep / error), each raising a clear typed exception.
Documentation
- Usage guide — worked examples for every bucketer and policy
- API reference — symbols, the
Rulemodel, runtime, exceptions - Integrations — pandas, Polars, and scikit-learn adapters
- Rule gallery — realistic portable JSON rules across ML use cases
- Benchmarks — reproducible speed and memory suite
- Changelog
When to use it
Use pickbuckets when ML buckets must be stable, reviewable, and identical
across training, batch scoring, online inference, and monitoring — tabular
preprocessing, feature-store transforms, score banding, drift slices, and
governed models such as credit scoring, fraud, churn, pricing, and insurance
risk. See the rule gallery for examples.
Development
ruff check .
mypy src/pickbuckets
pytest
python -m build
Contributions follow a few principles — keep the core import dependency-free, put integrations behind extras, fit once and transform from saved rules. See CONTRIBUTING.md.
Metadata
Release files for pickbuckets 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pickbuckets-0.5.0.tar.gz | 111.1 kB | Without provenance | Details for pickbuckets-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pickbuckets-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for pickbuckets-0.5.0-py3-none-any.whl |
Total release size: 155.3 kB
Release files / pickbuckets-0.5.0.tar.gz
| Download URL | pickbuckets-0.5.0.tar.gz |
|---|---|
| Size | 111.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0beb3b8d9ad7569ef9ca905d659c40f7caa49c41683eff0ed662a61b95f2fcd9
|
|
BLAKE2b-256 checksum How to use checksums |
234f5a3f50580e28fb5effd215d5577384799a4bbc61deef9e247e1722b503c4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.10
|
Release files / pickbuckets-0.5.0-py3-none-any.whl
| Download URL | pickbuckets-0.5.0-py3-none-any.whl |
|---|---|
| Size | 44.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bc54e5ed97f46cf3938e0de3c9c9e0a1b5885b12703f95a783480f560dd1b049
|
|
BLAKE2b-256 checksum How to use checksums |
fa70e1141a8616d2f37dca8ae98df15471aa3a4361948d19b8d3391db47a5e18
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.10
|
Security for pickbuckets 0.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.