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

Download files

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

Source Distribution

samesame-0.4.2.tar.gz (17.8 kB view details)

Uploaded Source

Built Distribution

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

samesame-0.4.2-py3-none-any.whl (21.0 kB view details)

Uploaded Python 3

File details

Details for the file samesame-0.4.2.tar.gz.

File metadata

  • Download URL: samesame-0.4.2.tar.gz
  • Upload date:
  • Size: 17.8 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for samesame-0.4.2.tar.gz
Algorithm Hash digest
SHA256 8d4cb9d405b9dcbe40353f48bca4b75239a1eec1882b7daa4b51ad1b2710c970
MD5 c31fa6312af10bd89841811c4e28564d
BLAKE2b-256 9b534002f91dcd6697b3866072e94a7e7fd4f2ef8f94722edad6a215d84511e2

See more details on using hashes here.

File details

Details for the file samesame-0.4.2-py3-none-any.whl.

File metadata

  • Download URL: samesame-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 21.0 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for samesame-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 13881c439291059921a6a34d0c6dc927aa173618047db2d5a650222ca60a2e0d
MD5 79b15f715ea5061de4ff753cb91846db
BLAKE2b-256 fec2021664f568218df2cf1db536642f14d4a4cc8d7940e31372144c663af291

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.4.2 This release

2 files

0.4.1

2 files

0.4.0

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.1

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

1 file

0.1.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