Explain metric shift shapley

Fit a cross-validated second-order ridge response surface and decompose its reference-to-current aggregate metric shift with an efficiency-preserving Shapley allocation, bootstrap uncertainty, and an explicit unexplained residual.

What it's for

Makes Gitrevio's 'why did this metric move?' and Shapley claims mathematically inspectable while preventing a descriptive decomposition from being marketed as causal attribution.

What you give it

Inputs split into evidence read from your connected systems, calibration your team owns, and numerical controls that affect precision but never the result's meaning.

Field Type Role Required
bootstrap_draws integer ≥ 200, ≤ 20000 Numerical control Optional
confidence_level number ≥ 0.8, ≤ 0.99 Your calibration Optional
current_observations array of objects (3 fields) ≥ 30 items Evidence Yes
feature_names array of string ≥ 1 item Evidence Yes
include_pairwise_interactions boolean Your calibration Optional
max_detail_rows integer ≥ 1, ≤ 500 Numerical control Optional
maximum_unexplained_fraction number ≥ 0, ≤ 1 Your calibration Optional
minimum_absolute_shift number ≥ 0 Your calibration Optional
minimum_out_of_sample_r_squared number ≥ -1, ≤ 1 Your calibration Optional
reference_observations array of objects (3 fields) ≥ 30 items Evidence Yes
ridge_penalty number ≥ 0.000001, ≤ 1000000 Your calibration Optional
seed integer Numerical control Optional

Each current_observations record

Field Type Required
features object Yes
id string (non-empty) Yes
outcome number Yes
Example input
{
  "bootstrap_draws": 200,
  "current_observations": [
    {
      "features": {
        "review_load": 2,
        "rework_rate": 0
      },
      "id": "shapley-current-0",
      "outcome": 4
    },
    {
      "features": {
        "review_load": 3,
        "rework_rate": 3
      },
      "id": "shapley-current-1",
      "outcome": 7.5
    },
    {
      "features": {
        "review_load": 4,
        "rework_rate": 6
      },
      "id": "shapley-current-2",
      "outcome": 11
    },
    {
      "features": {
        "review_load": 5,
        "rework_rate": 2
      },
      "id": "shapley-current-3",
      "outcome": 11
    },
    {
      "features": {
        "review_load": 6,
        "rework_rate": 5
      },
      "id": "shapley-current-4",
      "outcome": 14.5
    },
    {

Truncated for display — the full payload is 653 lines.

What you get back

This is the actual output of running the example above — computed by the same function the platform calls, not an illustration.

Example output
{
  "assumptions": [
    "The pooled second-order response surface predicts the declared aggregate metric adequately out of sample.",
    "Reference/current cohorts, feature definitions, and missingness policies are comparable.",
    "The decomposition allocates modeled association, including half of each pair interaction to each participant; it is not a causal Shapley effect."
  ],
  "attribution_count": 2,
  "attributions": [
    {
      "confidence_interval": [
        2.1472,
        6.1517
      ],
      "contribution": 3.9995,
      "feature": "review_load",
      "same_direction_probability": 1,
      "share_of_observed_shift": 0.9999
    },
    {
      "confidence_interval": [
        -0.3506,
        0.4125
      ],
      "contribution": 0,
      "feature": "rework_rate",
      "same_direction_probability": 0.51,
      "share_of_observed_shift": 0
    }
  ],
  "configuration": {
    "bootstrap_draws": 200,
    "confidence_level": 0.9,
    "maximum_unexplained_fraction": 0.5,
    "minimum_absolute_shift": 0.1,
    "ridge_penalty": 0.01
  },
  "decision": "metric_shift_decomposed",
  "diagnostics": {
    "bootstrap_fallback_draws": 0,
    "decomposition_efficiency_error": 0,
    "minimum_out_of_sample_r_squared": 0.05,
    "model_term_count": 3,
    "observed_shift_confidence_interval": [
      2.2275,

Truncated for display — the full payload is 64 lines.

How it works

Statistical audit & measurement — Check whether a number is fit to decide on: coverage, timing, reconciliation, and the gaps a dashboard hides.

  1. 1 Pool comparable reference and current observations, standardize declared factors, and fit a ridge response surface containing main effects and optional pair interactions.
  2. 2 Require stratified five-fold out-of-sample predictive fit before treating the response surface as explanatory.
  3. 3 Decompose the fitted mean shift into main-effect contributions and split every interaction contribution equally between its participating factors so contributions exactly sum to the modeled shift.
  4. 4 Bootstrap observations independently within each window, retain uncertainty and sign stability for every contribution, and keep the actual-minus-modeled shift visible as an unexplained residual gate.

Before you trust it

Every tool in the catalog ships with the conditions under which its answer is meaningful — and the conditions under which it should abstain instead of guessing.

Assumptions & guardrails

  • Metric definitions, weights, aggregate grain, sampling, missingness, dependence, and comparison windows correspond to the management claim being audited.
  • Reference/current cohorts use the same grain, feature definitions, outcome definition, inclusion rules, and missingness policy.
  • The response surface is predictively adequate; a good-looking attribution from a weak model must be rejected.
  • Association, instability, or measurement quality is not a causal effect and must not be converted directly into an individual employment decision.
  • These are Shapley allocations of modeled association, not causal Shapley effects; use a separately identified causal design before saying a factor caused the shift.

Minimum evidence

  • reference_observations: at least 30 rows/items
  • current_observations: at least 30 rows/items
  • feature_names: at least 1 rows/items

How to validate it

Validate on future periods or held-out aggregate units, compare with a simple baseline, and require stability across plausible metric definitions and decision thresholds.

Calibrating it to your org

Same for everyone

The mathematical kernel, validation rules, method version, and JSON output semantics are organization-independent; no tenant-trained coefficients or company benchmark is embedded in the function.

Specific to you

  • one governed reference/current projection with identical metric versions
  • zero-preserving aggregate rows and explicit missingness policy
  • candidate factors and allowed interactions
  • ridge penalty and held-out fit gate
  • practical shift and maximum unexplained-fraction thresholds

Calibration workflow

  1. 1 Define the management decision, target outcome, aggregate unit, privacy boundary, cadence, and prediction/intervention horizon for this organization.
  2. 2 Build a tenant-scoped historical cohort using only information available before each prediction or decision; preserve zero periods, censoring, assignment probabilities, and unresolved outcomes when the method requires them.
  3. 3 Estimate statistical parameters on training history, but obtain costs, utilities, risk tolerance, practical-effect thresholds, capacity, and policy constraints from accountable decision owners.
  4. 4 Validate on later time windows or held-out aggregate units at the deployment grain, against a simple baseline and the function-specific validation strategy.
  5. 5 Deploy only if the returned decision clears evidence, overlap, calibration, robustness, and guardrail checks; warning, unsupported, schema-gap, and fallback decisions are abstentions.
  6. 6 Monitor realized outcomes, data drift, coverage, and decision regret; recalibrate at a governed cadence or after a detected regime/definition change, never merely because a stakeholder dislikes the result.

Call it from your AI

You don't wire up 388 tools in your MCP client. The GitRevio MCP server exposes 18 tools, three of which let an agent search the catalog, read a tool's schema, and run it — so the assistant finds this one on its own.

gitrevio_capabilities_search
  { "q": "fit a crossvalidated secondorder ridge response" }
  → finds "explain_metric_shift_shapley"

gitrevio_capability_describe
  { "capability_id": "explain_metric_shift_shapley" }
  → returns the input schema and agent guidance shown on this page

gitrevio_capability_run
  { "capability_id": "explain_metric_shift_shapley", "arguments": { ... } }
  → returns the result shown above

Works in Claude Desktop, Claude Code, Cursor, Cline, Continue.dev, Goose and Aider. See the MCP server.

Related tools

Forecast hiring ramp capacity

Forecast an aggregate hiring plan with a locally calibrated hierarchical lognormal ramp-time model, Weibull productivity curves, correlated organization shocks, mentor-load displacement, commitment risk, and discounted capacity economics.

Forecasting & survival

Optimize stochastic flow control MPC

Optimize the next delivery-flow control with stochastic receding-horizon model-predictive control, serial queue dynamics, calibrated arrival and capacity scenarios, expected/CVaR cost, switching limits, exact sequence search, and a disclosed beam-search fallback.

Constrained optimization

Analyze info gap robust satisficing

Select a robust-satisficing action under severe uncertainty with Info-Gap Decision Theory: evaluate worst and best payoff across a governed nested uncertainty envelope, maximize the radius before a critical requirement fails, report windfall opportuneness, and use no scenario probabilities.

Decision analysis

Audit attention fragmentation evidence integrity

Audit consented point-in-time contributor identity, availability, privacy-safe calendar metadata and work-session lineage before reporting aggregate meeting load, protected focus blocks or cross-project switching.

Statistical audit & measurement

Audit attrition risk prediction integrity

Audit an attrition model's complete eligible cohort, point-in-time features, supportive-use governance, intervention-contaminated labels, competing outcomes, calibration, false positives and authorized subgroup error before any person-level use.

Forecasting & survival

Audit code knowledge concentration integrity

Audit file, module, service, or repository knowledge concentration from point-in-time substantive changes, reviews, incident response and documentation using identity-confidence filtering, recency decay, Bayesian ownership uncertainty, entropy-effective owners, HHI and leave-top-owner-out resilience—without turning contribution evidence into a person-performance score.

Sequential Bayesian & bandits

See every tool in People, retention & knowledge →

Ready to See Your Engineering work clearly?

Request a free demo