Ce regression intervals

From Moffran/calibrated_explanations · View interactive version

Ce regression intervals is an AI agent skill from the GitHub repository Moffran/calibrated_explanations. Configure and interpret CE regression intervals for percentile conformal and thresholded probabilistic modes.

How to use this skill

Skill file

CE Regression Intervals

You are configuring or interpreting regression intervals in CE. This skill

covers the three distinct regression modes defined in ADR-021. A fully

fit + calibrated WrapCalibratedExplainer (regression model) is required.

Load references/difficulty_estimator_guide.md for per-instance adaptive

intervals using DifficultyEstimator.

Three Modes — Decision Tree

Is threshold= provided?
├── NO  -> Mode 2: Percentile conformal intervals (CPS)
│         Use low_high_percentiles=(low%, high%)
│         Result: interval is a percentile band (e.g., 5th-95th percentile)
│
└── YES -> Mode 3: Thresholded probabilistic regression (CPS + Venn-Abers)
          Result: calibrated P(y <= threshold) with probability interval
          Interval semantics = probability mass (NOT a percentile band)

Mode 1 (classification) is handled by ce-pipeline-builder and ce-factual-explain.


Mode 2: Percentile Conformal Intervals

Use when: you want a confidence band around the regression prediction.

explanations = explainer.explain_factual(X_query)                              # default 5th-95th, 90% condfidence
explanations = explainer.explain_factual(X_query, low_high_percentiles=(10, 90))  # tighter, 80% confidence
explanations = explainer.explain_factual(X_query, low_high_percentiles=(-np.Inf, 90))  # upper bounded, 90% condfidence
explanations = explainer.explain_factual(X_query, low_high_percentiles=(10, np.Inf))  # lower bounded, 90% condfidence

How to read the output:

exp = explanations[0]
median = exp.prediction['predict']    # point estimate (CPS median)
low    = exp.prediction['low']        # e.g., 5th percentile
high   = exp.prediction['high']       # e.g., 95th percentile
# Invariant (ADR-021 §4): low <= median <= high

Mode 3: Thresholded Probabilistic Regression

Use when: you want the calibrated probability that the output exceeds a threshold.

explanations = explainer.explain_factual(X_query, threshold=50.0)              # scalar
explanations = explainer.explain_factual(X_query, threshold=(40.0, 60.0))      # two-sided

Key difference from Mode 2:


Calibration Engine (Context — ADR-021)

| Mode | Engine | What is calibrated |

|---|---|---|

| Classification | Venn-Abers only | P(class=k) with interval |

| Regression (percentile) | CPS only | Percentile bands |

| Regression (threshold) | CPS -> Venn-Abers | P(y <= t) with interval |


Choosing Interval Width

| Goal | Setting |

|---|---|

| Standard 90% interval | low_high_percentiles=(5, 95) (default) |

| Tighter 80% interval | low_high_percentiles=(10, 90) |

| Tight 50% IQR | low_high_percentiles=(25, 75) |

| Wider 98% interval | low_high_percentiles=(1, 99) |


Alternatives in Regression

alternatives = explainer.explore_alternatives(X_query, threshold=50.0)
alternatives = explainer.explore_alternatives(X_query, low_high_percentiles=(10, 90))

Out of Scope

Evaluation Checklist

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.