Instalar com Codex ou Claude Copie este prompt, cole no Codex, Claude ou outro assistente e deixe que ele revise a página da skill e instale para você.
Um comando direto ignora o prompt de revisão. Verifique a origem antes de executá-lo.
Instruções da origem · Visualização somente leitura
name
ce-pipeline-builder
description
Build CE-first end-to-end pipelines using WrapCalibratedExplainer with fit, calibrate, and explain or predict sequencing.
CE Pipeline Builder
You are implementing a CE-first pipeline. Load references/ce-first-policy.md
for the full policy text. Non-negotiable invariants are repeated inline below
for quick reference.
Mandatory CE-First Checklist (enforce in order)
Library check — if calibrated_explanations is not importable, fail fast:
pip install calibrated-explanations
Wrapper — always use WrapCalibratedExplainer. Never invent a new wrapper
class; never use CalibratedExplainer directly in user-facing code.
Fit — explainer.fit(x_proper, y_proper).
Assert explainer.fitted is True before proceeding.
Calibrate — explainer.calibrate(x_cal, y_cal).
Assert explainer.calibrated is True before proceeding.
Explain (standard) — explainer.explain_factual(X) or
explainer.explore_alternatives(X).
Explain (guarded / in-distribution) — when higher security or
in-distribution filtering is needed, use explainer.explain_guarded_factual(X)
or explainer.explore_guarded_alternatives(X) instead of the standard paths.
Also use when rule conditions of the form x < feature <= y are needed, since
the guarded APIs support this natively.
Conjunctions — explanations.add_conjunctions(...) or
explanations[idx].add_conjunctions(...).
Narratives & plots — .to_narrative(output_format=...) and .plot(...).
Calibrated by default — never return uncalibrated outputs unless
the user has explicitly requested them.
Minimal Working Skeleton
Adapt the task type (binary / multiclass / regression) based on the user's
data and model. Choose from the three templates below:
Binary classification
from __future__ import annotations
import numpy as np
from calibrated_explanations import WrapCalibratedExplainer
# --- Data split ---------------------------------------------------------# x_proper, y_proper : proper training set (used for model training)# x_cal, y_cal : calibration set (must NOT overlap with x_proper)# X_query : instances to explain# --- Build pipeline -----------------------------------------------------
explainer = WrapCalibratedExplainer(model) # model: any sklearn-compat
explainer.fit(x_proper, y_proper)
assert explainer.fitted isTrue
explainer.calibrate(x_cal, y_cal)
assert explainer.calibrated isTrue# --- Explain ------------------------------------------------------------
explanations = explainer.explain_factual(X_query)
# Optional: add feature conjunctions
explanations.add_conjunctions(max_rule_size=3)
# Optional: narrativeprint(explanations[0].to_narrative())
# Optional: plot
explanations[0].plot()
Multiclass classification
Same scaffold as binary. The explain_factual call returns one explanation
object per query instance, with per-class calibrated probabilities available in
explanations[i].prediction["__full_probabilities__"].