Skip to main content

whowhen

DOI

Check a table of repeated observations per unit (patients, machines, loans, users, vessels) for two signals a model can exploit without predicting anything:

  • who: can a row be matched to the unit it came from?
  • when: can two rows of one unit be put in time order?

If the answer to either is yes, a model evaluated on your data may be scoring well by recognizing units or reading the clock.

Install

pip install whowhen

Use

From the terminal, give a CSV file and the names of its columns:

whowhen rows.csv --unit patient_id --time hour --event sepsis

If the rows are not ordered in time (several samples per patient, several measurements per batch), leave the time column out:

whowhen samples.csv --unit patient_id --event tumour

In Python, pass a pandas DataFrame (your data table):

import pandas as pd
import whowhen as ww

df = pd.read_parquet("stays.parquet")
print(ww.report(df, unit="patient_id", time="hour", event="sepsis"))
print(ww.report(samples, unit="patient_id", event="tumour"))   # no time order

Both interfaces run the same checks.

Setting Required Default What it is
df yes the table, one row per observation
unit yes the column naming the unit
time no none the column giving when the row was observed; leave it out if the rows are not ordered in time
event no none a column that is nonzero where the event happens
features no every numeric column the columns to check: a list, or a dict of named lists to compare side by side
horizon no none for forecasting tasks: how far ahead the event is predicted, in the time column's scale (12, or "12h" for datetimes)
repeats no 4 how many times every check is run
random no False draw held-out units at random instead of the fixed groups
n_pairs no 20000 the most row pairs each run uses; smaller tables use what they have

What runs depends on what you give:

You give You get
unit only the identity audit, the individual-or-type test, the per-column ranking for identity
unit and event plus the overlap check
unit and time the identity and timing audits, the timing placebo, the individual-or-type test, the audits by short and long gap, the per-column ranking
plus event the overlap check, the chronological control, the time-cut split, the clock baseline
plus horizon those three run as a forecast: "does the event come within this long after the row?"

A check that cannot run is listed at the end of the report with the reason.

To compare choices made before modeling, such as raw values against a carried-forward or imputed version, put both versions in the table and name them. Every check then runs once per named set, the audits on the same pairs and the event checks on the same splits:

ww.report(df, unit="patient_id", time="hour",
          features={"raw": raw_cols, "carried_forward": filled_cols})

To see the library work before pointing it at your own data, run it on a synthetic table where the right answers are known:

whowhen demo

What the report contains

Identity audit and timing audit. Both train a classifier on pairs of rows from units with no recorded event, built so that the two classes look the same unless the signal is there. The gap between the two rows of a pair is chosen from the data and stated in the report.

Audit The pair Label AUC 0.5 means
identity two rows a set time apart same unit, or two different units seen at the same two times rows carry nothing that says which unit produced them
timing two rows of one unit a set time apart which row is the later one a unit's rows carry nothing that says when they were recorded

Units are split into training and held-out sides before any pair is drawn, so the AUC is measured on units the classifier never saw. The interval comes from resampling held-out units, pooled over repeats.

Timing placebo. The timing audit again, with the later row taken from a different unit observed at that time. If this score is near 0.5, the timing signal is each unit's own history. If it is near the timing audit's score, the signal is change shared by all units, such as calendar drift or a change in how every unit is recorded.

Individual or type. The identity audit is reported twice. With random impostors the different unit is any other unit, so a high score can mean "these two rows are from different kinds of unit" (a tug and a tanker). With nearest impostors the different unit is one of the units most similar to the first, by per-unit column averages. If the score stays high, individual units are recognizable. If it falls toward 0.5, the columns identify the kind of unit, not the individual.

Short and long gaps. Both audits again, once with the two rows of a pair in the shorter half of the gap range and once in the longer half. If identity stays high at the long gap, units stay recognizable as time passes.

Columns. For each column: the audit using that column alone, and how much the full score drops when that column is removed.

Overlap check. Needs event. It scores the same test rows twice with the same number of training rows per class: once with the test units held out of training, once with other rows of those units swapped in. The gap between the two scores is how much sharing units between training and test is worth to this classifier on your task.

Chronological control. The same check, testing the later half of each test unit's rows and letting training see the earlier half: does a unit's own past help predict its own future?

Time-cut split. The same check with a single cut in the time column: test rows come after it, training rows before it. When the time column is a shared calendar, this is the usual split by date, and the gap shows how much unit overlap such a split leaves in place.

Clock baseline. Many event tasks can be scored well above chance from one number: how long the unit has been observed. This fits the same classifier on the clock alone, on your columns alone, and on both, with units held out, and reports what the columns add once the clock is known.

What the numbers do not mean

An audit AUC above 0.5 says the signal is present in the columns. It does not say your model uses it.

The overlap check does not say so either. It measures what unit overlap is worth to whowhen's classifier, on your columns and your outcome, under the split it names. A gap there shows the evaluation is sensitive to unit overlap. To learn what your own model gains, train it both ways.

An AUC near 0.5 does not certify an evaluation. It says this classifier, on these columns, found nothing. Leakage through the label, through preprocessing fitted on test rows, or through columns not in the table is outside what these checks see.

When it applies

  • many units (hundreds or more), each observed more than once;
  • for the identity audit, several units observed at the same time values, since the different-unit pair is matched on time;
  • without a time column, a pair is two rows of one unit or one row each from two units, with no matching on time. If the rows do have an order, give the time column: unmatched pairs can also be told apart by anything that changed between the times the units were observed;
  • with horizon, an event column flagged on the row where the event happens, not on every row of the unit.

With horizon, a unit's last row is taken as the end of its follow-up. A row of a unit with no event counts as "no event within the horizon" only if the unit was still observed one horizon later; other such rows are left out, and the report says how many. Under the chronological and time-cut splits, a row from before the cut is trained on only if its horizon has passed by the cut, so no label is used before it could have been known. If your table ends a unit's rows before its follow-up truly ends, extend the rows or shorten the horizon.

It does not apply to tables with one row per example and no repeated unit.

Repeats and repeatability

repeats=N is one number: every check runs N times. Units fall into N + 1 fixed groups, by a hash of the unit identifier, and each run holds out a different group:

repeats Each run tests
1 one half of the units
2 one third
3 one quarter
4 (default) one fifth

More repeats give a steadier answer, but each run then tests a smaller share of the units, so very high values suit only large tables.

By default the same call on the same table gives the same numbers every time. random=True draws the held-out units and the pairs at random instead, differently on each run, and the report states the seed that run used.

The classifier

The checks use mojolearn's GradientBoosting with oblivious (symmetric) trees. mojolearn ships wheels for macOS on Apple silicon and Linux on x86-64. On other platforms, including Windows, CatBoost is installed and used instead, with the same settings. The report names the whowhen version and DOI, and the classifier that ran with its version and, where the classifier declares one, its DOI.

Independent runs are spread across all cores. Set the WHOWHEN_JOBS environment variable to use fewer.

Command line

whowhen rows.parquet --unit patient_id --time hour --event sepsis
whowhen demo

CSV and Parquet files are supported. Use whowhen --help for report options or whowhen demo --help for demo options.

To use a report in a script or a scheduled job, say what counts as a failure:

whowhen rows.parquet --unit patient_id --time hour --event sepsis \
    --fail-if "overlap_gap > 0.02" --fail-if "clock_gain < 0.01"

The command exits with 1 if any condition holds, and with 2 if a condition names a check that did not run. You choose the conditions; there are no built-in thresholds.

Name The number
identity, identity_nearest identity AUC against any other unit, and against the most similar units
timing, placebo timing AUC, and its placebo
overlap_gap, chronological_gap, time_cut_gap overlap AUC minus disjoint AUC under each split
clock AUC of the clock alone
clock_gain what the columns add once the clock is known

With several named feature sets, each number is the one furthest from a clean result: the highest AUC, the highest gap, the lowest clock gain. A high identity AUC is normal for many tables and is not by itself a failure; the gaps say whether it matters for your task.

Citing

The method is described in:

Andrew Hendel. Auditing Identity and Timing Signals in Operational Logs. 2026. Under review.

The library is archived on Zenodo. This DOI always points to the newest version: 10.5281/zenodo.24406266.

See CITATION.cff.

License

Apache License 2.0. See LICENSE.

Metadata

Release files for whowhen 0.2.1

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

Source distribution (sdist)

Source distribution for whowhen 0.2.1
File Size Uploaded Provenance Actions
whowhen-0.2.1.tar.gz 49.6 kB With provenance Details for whowhen-0.2.1.tar.gz

Built distribution (wheel)

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

Total release size: 92.2 kB

Release files / whowhen-0.2.1.tar.gz

Download URL whowhen-0.2.1.tar.gz
Size 49.6 kB
Tags Source
SHA-256 checksum
How to use checksums
2221d5bbcac29877e406c269602483c7ab9f5a69f03e7f8fe84c7c7ed663cd71
BLAKE2b-256 checksum
How to use checksums
ec3caadefcc7e7add0534edb859907fd363ff44a3f272bc5e5fbcb9457736ccf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 21, 2026.

Transparency log

Release files / whowhen-0.2.1-py3-none-any.whl

Download URL whowhen-0.2.1-py3-none-any.whl
Size 42.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a27fcdab8fd0d7b43cbe088c024b2cca436b63e876e5d27ce6a5854632d21884
BLAKE2b-256 checksum
How to use checksums
3ad8e41849972a03a4d196f311cb8a45b47e920f10bb2d1601428b7d8a6dcc99
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 21, 2026.

Transparency log

Security for whowhen 0.2.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.

Select from 2 files

Attestation for whowhen-0.2.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 Nov 21, 2026.

Transparency log

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.

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