WhyChanged
Something moved in your dashboard. WhyChanged turns every significant shift in
a tracked metric into a sentence a stakeholder can act on — and localizes the
slow regime changes that a simple day-over-day comparison misses.
Why this exists
Dashboards tell you a number moved. They rarely tell you why, and they almost
never catch the dangerous case: a metric that drifts onto a new level over two
weeks without any single day looking alarming. WhyChanged reads a metric's time
series and explains each shift in plain English, linking it to a cause when you
have one recorded.
What it does
- Step detection. Compares each point to the previous one (or to an
explicit
baseline column) and flags changes past a percent or absolute
threshold. A zero (or numerically zero) baseline has no meaningful percentage,
so those shifts are judged on the absolute delta and marked
comparison: "absolute_delta" in the finding metadata.
- Regime detection. For series of 10+ points (configurable), runs a
binary-segmentation changepoint scan to find where the series settled onto a
new level — the slow shifts consecutive deltas never flag. Each regime
finding carries a
changepoint date, a confidence score, the segment means,
a settling_points count, and method: "binary-segmentation-v2". Shifts that
revert inside the settling window are dropped, and a regime shift that
merely corroborates an already-reported step is folded into that step instead
of emitted twice.
- Severity you can gate on. A drop to zero or a 100%+ move is
high;
double the threshold is medium; anything past the threshold is low.
- Reasons, not proven causes. If a row carries a
reason, it is split into
occurrence_cause (the recorded reason) and escape_cause (only when your
data has an escape_cause/detection_gap column), with
verification_needed: true. Every such finding says: "Treat as correlation,
not proven causation."
- Contributor drill-down. Significant shifts list the top three segments
by absolute delta contribution under
metadata.top_contributors. They are
always labelled top contributors, never causes. summary.contributions
holds the drill-down for the strongest shift.
- Optional correlation hook. Point
--findings at a ReadyPack-style report;
shifts within one day of a finding get a candidate_driver and a warning that
the link is date correlation only.
What it is not
It does not guess causes it wasn't given. If you don't record a reason, you get
a clear "what moved" explanation and nothing more — top contributors and
candidate drivers are correlations, not causal claims. It is not a forecasting
tool and holds no opinion about whether a shift is good.
Install
Python 3.10+, no runtime dependencies.
git clone https://github.com/hexsyro/WhyChanged.git
cd WhyChanged
python -m pip install .
For development:
python -m pip install -e ".[dev]"
python -m pytest
Usage
whychanged examples/sample.csv
Columns are matched loosely: metric name from metric, metric_name,
series, kpi, or tracked_metric; date from date, day, period,
timestamp, as_of, or week; value from value, metric_value,
current_value, score, or current; an optional prior value from
previous_value, baseline, prev_value, baseline_value, prior, or
previous; and an optional cause from reason, findings, cause, notes,
driver, explanation, or linked_findings.
Options
| Flag |
What it does |
--threshold-pct PT |
Percent change to consider significant (default 10.0) |
--threshold-abs N |
Absolute change to also consider significant; also the gate when the baseline is zero (default 0.0, any nonzero delta) |
--settling-window N |
Points after a changepoint checked for reversion and used for step dedup (default 2) |
--min-points N |
Minimum series length for the regime scan (default 10) |
--group-by COLUMN |
Dimension column for the contributor drill-down (default: auto-detect non-metric/date/value/reason columns) |
--findings FILE |
ReadyPack-style findings report (or list of reports) to correlate against shift dates |
--config FILE |
JSON config; explicit flags win. Invalid option value types exit 2 with a clear message |
--format {table,json,csv,md} |
Output format (default table) |
--output FILE |
Write to file instead of stdout |
--fail-on {none,low,medium,high} |
Exit 1 if any finding is at or above this severity |
--version |
Print version and exit |
Output (json)
{
"tool": "whychanged",
"version": "0.2.0",
"result_schema_version": "1.1",
"status": "success",
"findings": [
{
"severity": "medium",
"field": "metric",
"message": "Metric 'signups' rose 58.4% from 101.00 to 160.00 as of 2026-01-07. Linked cause: launched referral program Treat as correlation, not proven causation.",
"record_id": "r7",
"metadata": {
"metric": "signups",
"direction": "rose",
"delta_pct": 58.42,
"delta_abs": 59.0,
"from": 101.0,
"to": 160.0,
"comparison": "percent",
"reason": "launched referral program",
"occurrence_cause": "launched referral program",
"escape_cause": null,
"verification_needed": true,
"corroborates_record_id": "r7"
}
}
],
"warnings": [],
"summary": {
"result_schema_version": "1.1",
"checked": 17,
"shifts_detected": 3,
"per_metric": {
"signups": {"shifts": 1, "first_value": 100.0, "last_value": 161.0, "net_change_pct": 61.0},
"churn_pct": {"shifts": 2, "first_value": 2.1, "last_value": 3.7, "net_change_pct": 76.19}
},
"skipped": false,
"skip_reason": null,
"deduplicated_regime_shifts": 1,
"contributions": null
}
}
Findings with "method": "binary-segmentation-v2" in their metadata come from
the regime scan, not the point-to-point comparison. per_metric includes every
metric seen in the input, even those with shifts: 0. skipped/skip_reason
say whether any usable rows were found; status stays success either way.
Using it in CI
whychanged metrics.csv --fail-on medium || exit 1
Exit codes: 0 ran fine, 1 gate tripped, 2 input broken.
Library use
from whychanged import RESULT_SCHEMA_VERSION, ToolResult, run
result = run(rows, {"threshold_pct": 15, "group_by": "region"})
assert result.summary["result_schema_version"] == RESULT_SCHEMA_VERSION
result.summary["shifts_detected"]
run() coerces option values through defensive helpers, so malformed types fall
back to defaults instead of raising. The CLI additionally rejects invalid
option value types in a config file with exit code 2 and a clear stderr message.
Limitations, honestly
- No causality. A recorded
reason is reported, never inferred. Correlation
in a spreadsheet is not causation, and WhyChanged doesn't pretend otherwise.
- Regime scan needs volume. Ten points minimum by default (
--min-points
can lower it); with fewer, only point-to-point steps are reported.
- One metric per series. If your rows mix unrelated metrics under the same
name, they'll be treated as one series — keep metric names distinct.
- Percentages and zeroes. A baseline of zero (or
abs(baseline) < 1e-12)
can't produce a meaningful percentage. Those shifts are compared using
threshold_abs (or any nonzero delta when it is unset), the message reports
the absolute delta, and the finding is tagged
metadata.comparison = "absolute_delta".
- Contributors are not causes. Top contributors show where the delta sat in
your dimensions; candidate drivers are date correlations only. Both need
verification.
[0.2.0] - 2026-11-19
Added
- Result schema
1.1: summary.result_schema_version, summary.skipped, and
summary.skip_reason; RESULT_SCHEMA_VERSION and ToolResult exported from
whychanged.
- Changepoint confidence, segment means, changepoint date, and settling-window
metadata (
method: "binary-segmentation-v2"); settling_window and
min_points options.
- Top-contributor drill-down via
group_by or auto-detected dimension columns,
plus summary.contributions for the strongest shift.
- Structured cause fields (
occurrence_cause, escape_cause,
verification_needed) and the "Treat as correlation, not proven causation."
caveat.
- Optional
findings correlation hook for ReadyPack-style reports, with a
candidate_driver and correlation-only warning.
- CLI flags for the new options; config value types are validated (invalid
types exit 2 with a clear message).
Fixed
- Deduplicated regime findings that merely corroborate a step: the step carries
metadata.corroborates_record_id instead of a second, contradictory finding.
- Zero/near-zero baselines now use absolute-delta significance and are labelled
comparison: "absolute_delta" instead of reporting a bogus percentage.
- Direction is computed from the raw delta, including for negative baselines.
per_metric now includes stable metrics with last_value and
net_change_pct, and the changepoint branch updates them too.
- Timezone-aware timestamps are converted to UTC before tzinfo is dropped.
- Dict/list reasons render as JSON instead of Python reprs.
Inspiration
License
MIT. See LICENSE.