Ce alternatives explore

From Moffran/calibrated_explanations · View interactive version

Ce alternatives explore is an AI agent skill from the GitHub repository Moffran/calibrated_explanations. Generate and interpret CE alternative and counterfactual explanations, including ensured filters and alternatives-specific plot workflows.

How to use this skill

Skill file

CE Alternatives Explorer

You are producing alternative calibrated explanations — counterfactual rules

that show what feature changes would produce a different prediction.

The CE-First pipeline (fit + calibrate) is a prerequisite. If not in place,

invoke ce-pipeline-builder first.

For all post-generation interaction (plot, narrative, add_conjunctions,

filter_rule_sizes, filter_features) see ce-explain-interact.

Load references/alternatives_api_reference.md for the ensured framework,

plot styles, ranking controls, and conjunction API.


Two Entry Points

Standard path

alternatives = explainer.explore_alternatives(X_query)

Explaining all classes (multiclass)

multi_alts = explainer.explore_alternatives(X_query, multi_labels_enabled=True)

Guarded path (production / unknown distributions — ADR-032)

from calibrated_explanations.explanations.guarded_options import GuardedOptions
alternatives = explainer.explore_alternatives(X_query, guarded_options=GuardedOptions())

Guarded variant: out-of-distribution instances are flagged rather than silently

included. Use in production or when the input distribution is unknown.

API note: explore_guarded_alternatives(...) was REMOVED in v0.11.3. The guarded=True

boolean kwarg was removed in v0.11.5. Always use guarded_options=GuardedOptions().


Threshold Semantics

For classification — change the decision boundary:

alternatives = explainer.explore_alternatives(X_query, threshold=0.7)

For regression — see ce-regression-intervals for full semantics:

alternatives = explainer.explore_alternatives(X_query, threshold=50.0)
alternatives = explainer.explore_alternatives(X_query, threshold=(40.0, 60.0))

Output Types

AlternativeExplanations      (collection — returned by explore_alternatives)
   [i] -> AlternativeExplanation  (per-instance)

The prediction dict structure and interval invariant are identical to factual

explanations (pred['low'] <= pred['predict'] <= pred['high']), but the

direction of the rules is counterfactual (opposing, not supporting).


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.