Skip to main content

samesame

Python Downloads UAI 2022

Same, same but different ...

Bring your own score — the risk you care about, the errors your model makes, how much you trust it, or when something looks off. samesame tells you two things: did the source and target scores shift, and did it get worse?

Data and model monitoring rarely gives you labels, and univariate checks miss hidden multivariate (high-dimensional) shifts. A score reduces each observation to a single interpretable and insightful number.

Installation

python -m pip install samesame

Requires Python 3.12+, numpy, scipy, and scikit-learn.

Source is the reference distribution (training data or a past deployment); target is the current deployment under evaluation.

It separates two questions that are easy to conflate:

  • ss.test_shift: a broad, two-sided screen for any shift.
  • ss.test_harm(..., worse="higher"): a focused, one-sided test for movement toward the tail you declare harmful (worse="lower" if that tail is the small one).
import numpy as np

import samesame as ss

rng = np.random.default_rng(12345)
source_scores = rng.normal(loc=0.0, scale=1.0, size=600)
target_scores = rng.normal(loc=0.6, scale=1.0, size=600)

shift = ss.test_shift(source=source_scores, target=target_scores, rng=rng)
harm = ss.test_harm(
    source=source_scores,
    target=target_scores,
    worse="higher",  # larger = more harm (e.g., risk)
    rng=rng,
)

print(f"Shift p-value: {shift.pvalue:.4f}")
# → Shift p-value: 0.0002
print(f"Harm  p-value: {harm.pvalue:.4f}")
# → Harm  p-value: 0.0001

The small p-values provide strong evidence that the target distribution shifted and moved in an adverse direction. We therefore reject both the null of no shift and the null of no harmful shift at any reasonable significance level.

Workflow

  1. Choose a score that represents the outcome you care about. Generate it out of sample if it comes from a fitted model.
  2. Ask whether anything changed with ss.test_shift.
  3. Ask whether the change is harmful with ss.test_harm(..., worse=...). Specify in advance whether higher or lower scores indicate harm.
  4. Address poor feature overlap with ss.domain_weights only when it is a real concern. Weighting focuses the comparison on a different population: the region of common support. Details: Weight for common support.

Where next

Metadata

Release files for samesame 0.4.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for samesame 0.4.2
File Size Uploaded Provenance Actions
samesame-0.4.2.tar.gz 17.8 kB Without provenance Details for samesame-0.4.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for samesame 0.4.2
File Interpreter ABI Platform Actions
samesame-0.4.2-py3-none-any.whl Python 3 none any Details for samesame-0.4.2-py3-none-any.whl

Total release size: 38.9 kB

Release files / samesame-0.4.2.tar.gz

Download URL samesame-0.4.2.tar.gz
Size 17.8 kB
Tags Source
SHA-256 checksum
How to use checksums
8d4cb9d405b9dcbe40353f48bca4b75239a1eec1882b7daa4b51ad1b2710c970
BLAKE2b-256 checksum
How to use checksums
9b534002f91dcd6697b3866072e94a7e7fd4f2ef8f94722edad6a215d84511e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.25 {"installer":{"name":"uv","version":"0.9.25","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}

Release files / samesame-0.4.2-py3-none-any.whl

Download URL samesame-0.4.2-py3-none-any.whl
Size 21.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
13881c439291059921a6a34d0c6dc927aa173618047db2d5a650222ca60a2e0d
BLAKE2b-256 checksum
How to use checksums
fec2021664f568218df2cf1db536642f14d4a4cc8d7940e31372144c663af291
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.25 {"installer":{"name":"uv","version":"0.9.25","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}

Security for samesame 0.4.2

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.

Release history Release notifications | RSS feed

This release

0.4.2 This release

2 release files No provenance

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