Skip to main content

metrics-adjuster

metrics-adjuster computes conventional and adjusted group-aware metrics for binary prediction models. It provides a typed Python API, a command-line interface, deterministic synthetic demos, self-contained HTML reports, and optional parquet artifacts for downstream inspection.

Installation

Install from PyPI (Python 3.11+):

python -m pip install metrics-adjuster

That one command installs both the metrics-adjuster CLI and the Python API. Parquet input and artifact output work out of the box (pyarrow is included).

Other setups:

  • CLI only, without a project environment: pipx install metrics-adjuster
  • uv project: uv add metrics-adjuster
  • conda or mamba env: run the pip command above inside your activated environment
  • pinned release: python -m pip install "metrics-adjuster==1.1.0"
  • source checkout: see Contributing

Quick Example

metrics-adjuster demo \
  --output-dir demo_outputs \
  --report \
  --save-artifacts \
  --report-figures

For caller-provided CSV or Parquet data:

metrics-adjuster run \
  --input cohort.csv \
  --output-dir adjusted_metric_outputs \
  --group-col group \
  --ref-group ref \
  --response-col outcome \
  --risk-col risk \
  --id-col patient_id \
  --metrics aTPR,aPPV,aNB,aHR \
  --report \
  --save-artifacts \
  --report-figures

The CLI writes one CSV per adjusted metric. Optional outputs include:

  • report.html when --report is enabled
  • figure_1_calibrated_density.svg and figure_2_weight_ratio.svg when --report-figures is also used
  • calibration.parquet and weights.parquet when --save-artifacts is used

Python API

from pathlib import Path

from metrics_adjuster import ColumnSpec, MetricConfig, OutputConfig, adjusted_metrics
from metrics_adjuster.synthetic import generate_synthetic_metrics_data

frame = generate_synthetic_metrics_data(n=600, seed=2026)
config = MetricConfig(
  columns=ColumnSpec(group="group", response="outcome", risk="risk", id="patient_id"),
  ref_group="ref",
  output=OutputConfig(
    calibration_path=Path("artifacts/calibration.parquet"),
    density_ratio_path=Path("artifacts/weights.parquet"),
    include_intermediates=True,
  ),
  random_state=2026,
)

result = adjusted_metrics(frame, config)
print(result.metrics["aTPR"])
print(result.weighted[["cal_risk", "dens_ratio"]].head())

For reports and standalone figures, use adjusted_metrics_report(...) and write_report_figures(...). See the API manual.

Documentation

Citation

If you use metrics-adjuster in published work, cite it as:

APA:

Park, S. (2026). metrics-adjuster (Version 1.1.0) [Computer software]. GitHub. https://github.com/SaehwanPark/metrics-adjuster

AMA:

Park S. metrics-adjuster [computer program]. Version 1.1.0. Published 2026. Accessed June 24, 2026. https://github.com/SaehwanPark/metrics-adjuster

License

metrics-adjuster is distributed under the GNU General Public License v3.0.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

metrics_adjuster-1.1.0.tar.gz (39.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

metrics_adjuster-1.1.0-py3-none-any.whl (25.3 kB view details)

Uploaded Python 3

File details

Details for the file metrics_adjuster-1.1.0.tar.gz.

File metadata

  • Download URL: metrics_adjuster-1.1.0.tar.gz
  • Upload date:
  • Size: 39.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for metrics_adjuster-1.1.0.tar.gz
Algorithm Hash digest
SHA256 e0e1adb8123aa0a1ec1533b3d242e61bf79a7e6d165768be326e5b902acc6e04
MD5 dce4a6273ce21cc685816969bc158c59
BLAKE2b-256 899ce9d9c4e70f372ece093d224a72192c3674e31b77e75e9ed4be23ccf74064

See more details on using hashes here.

File details

Details for the file metrics_adjuster-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: metrics_adjuster-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 25.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for metrics_adjuster-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ea702db91e35a3bd84dd674c770bb5e901928caee9822251bd882f2da86cefd2
MD5 fd7ab93b23c051233222339d0fe06eb6
BLAKE2b-256 80f2c9edaaf3bfd0668e71fb5bf1d45eb1e23e361f07258089f8b7f4495aeab8

See more details on using hashes here.

Release history Release notifications | RSS feed

1.1.3

2 files

1.1.2

2 files

1.1.1

2 files

This release

1.1.0 This release

2 files

1.0.2

2 files

1.0.1

2 files

1.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page