robustkit
⚠️ Under active development. This is an early placeholder release to claim the package name on PyPI. The API is incomplete and may change without notice. Not yet recommended for production use.
Practical tools for robust analysis of a single continuous relationship: y as a function of one continuous x.
The guiding idea: a conclusion that survives multiple fitting methods
is more trustworthy than one that only holds under a single model.
robustkit makes it easy to compare Huber, Tukey biweight, and OLS
fits side by side, identify and quantify the influence of individual
observations, and get honest, bias-corrected uncertainty estimates.
Status
robustkit.core (trend fitting, stability, diagnostics, uncertainty,
consistency checks), robustkit.segmentation (hierarchical grouping,
per-segment analysis), and robustkit.information (mutual-information
feature ranking) are stable and tested. A more advanced
information-theoretic pairing layer (conditional MI for a second
variable, synergy/redundancy scoring) is planned but not yet included.
Installation
git clone https://github.com/<your-username>/robustkit.git
cd robustkit
pip install -e ".[dev]"
Quickstart
import numpy as np
from robustkit import (
fit_huber_trend, fit_tukey_trend, predict_trend,
model_stability_pct, cooks_diagnostic, cook_impact,
bootstrap_band, bca_bootstrap_ci,
)
# x: a single continuous predictor, y: a single continuous outcome
x = np.random.default_rng(0).uniform(20, 60, 200)
y = 1000 + 50 * x - 0.4 * x**2 + np.random.default_rng(1).normal(0, 500, 200)
fit = fit_huber_trend(x, y, degree=2)
y_pred = predict_trend(fit, x_new=[30, 40, 50])
stability = model_stability_pct(x, y)
print("Median % spread between Huber/Tukey/OLS:", stability["median_pct_diff"])
diag = cooks_diagnostic(x, y)
impact = cook_impact(x, y, diag["flagged_indices"])
print("Median % change in curve if flagged points removed:", impact["median_pct_change"])
band = bootstrap_band(x, y)
ci = bca_bootstrap_ci(x, y, statistic_fn=lambda x_, y_: np.median(y_))
See examples/quickstart_tutorial.py for a complete, runnable walkthrough.
Segmentation
Run any robustkit.core analysis independently across subgroups of a
larger dataset, with automatic fallback to coarser groupings when a
finer one is too small to analyze reliably:
from robustkit import hierarchical_segment, apply_by_segment, model_stability_pct
hierarchy = [["department", "level", "status"], ["level", "status"], ["status"]]
segmented = hierarchical_segment(df, hierarchy, min_size=20)
report = apply_by_segment(
segmented, segment_col="segment_id", x_col="age", y_col="value",
analysis_fn=model_stability_pct,
)
apply_by_segment works with any function shaped like
analysis_fn(x, y, **kwargs) -> dict -- built-in ones
(model_stability_pct, cook_impact, bca_bootstrap_ci, ...) or your
own. Only scalar values in the returned dict end up in the report
table; segments below min_points are skipped rather than causing an
error.
Feature ranking (information)
Rank features by mutual information with a target, normalized by each feature's own entropy, and classify them into four quadrants:
from robustkit import rank_features, quadrant_report, plot_feature_space
ranking = rank_features(df, target="value")
report = quadrant_report(df, target="value") # adds a `quadrant` column
plot_feature_space(df, target="value") # same quadrants, visualized
quadrant_report and plot_feature_space always agree on quadrant
assignment -- both route through the same thresholding logic.
Caveat: default thresholds are the median mutual information /
efficiency across the ranked features. With only a handful of
features, this can put a genuinely weak feature in the same "high"
half as a strong one, since roughly half of any list sits above its
own median regardless of how large the actual gap is. Median
thresholding becomes meaningful with a reasonably large feature set;
for a handful of candidates, read the raw mutual_information /
information_efficiency values directly rather than relying on the
quadrant label alone.
See examples/information_tutorial.py for a complete walkthrough.
Design principles
- One continuous x, one continuous y at the core. This keeps every function's output visually and numerically interpretable (a curve you can plot, a band you can read).
- Diagnosis and action are separate steps.
cooks_diagnosticflags candidates;cook_impacttells you whether removing them actually changes anything. - OLS is a reference point, not the enemy. Comparing robust fits against OLS is how you know whether robustness mattered at all.
License
MIT -- see LICENSE.
Metadata
Release files for robustkit 0.0.1
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 |
|---|---|---|---|---|
| robustkit-0.0.1.tar.gz | 19.0 kB | With provenance | Details for robustkit-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| robustkit-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for robustkit-0.0.1-py3-none-any.whl |
Total release size: 37.1 kB
Release files / robustkit-0.0.1.tar.gz
| Download URL | robustkit-0.0.1.tar.gz |
|---|---|
| Size | 19.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3c8117b41e9165d476d17a1dbff1ba5e1ce1aec9f7f1d6f60b97a3f60b0cc4ee
|
|
BLAKE2b-256 checksum How to use checksums |
28c0c84c1fcaa366d72c328edb1d1c9947252068fb177e6b7207379c31f15752
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.
Transparency logRelease files / robustkit-0.0.1-py3-none-any.whl
| Download URL | robustkit-0.0.1-py3-none-any.whl |
|---|---|
| Size | 18.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1dfcba4c5af5118b273d1d50116731fc8454dbbe452b41d34948df9597b47737
|
|
BLAKE2b-256 checksum How to use checksums |
e05b932828fc3bed5f59debecd5ccceacab4d410b0842178623bef8911d45409
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.
Transparency logSecurity for robustkit 0.0.1
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for robustkit-0.0.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.
Transparency logA 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.