Ce data preparation

From Moffran/calibrated_explanations · View interactive version

Ce data preparation is an AI agent skill from the GitHub repository Moffran/calibrated_explanations. Validate and preprocess input data for CE pipelines, handle mixed types and categorical features, and configure encoding per ADR-002 and ADR-009.

How to use this skill

Skill file

CE Data Preparation

You are helping users prepare their data for use with calibrated-explanations.

Required references

Use this skill when

Common scenarios

1. Categorical features

CE requires numeric input by default. For categorical features:

explainer = WrapCalibratedExplainer(model, auto_encode='auto')
explainer.fit(X_train, y_train)  # auto-encoding activates here

deterministically.

preprocessor parameter.

2. Mixed types (DataFrame input)

When passing a DataFrame with mixed dtypes:

guidance listing the offending columns.

3. Missing values (NaN)

CE does not impute missing values by default:

with imputation if needed.

4. Unseen categories at inference

Per ADR-009, the unseen_category_policy controls behavior:

5. Mapping export/import

After fitting, you can export and import preprocessing mappings:

mapping = explainer.export_mapping()  # JSON-safe dict
# ... save to file or transfer ...
explainer.import_mapping(mapping)     # restore on another instance

Validation error diagnostics

When CE raises input errors, check:

  1. Column types: Are all columns numeric? If not, enable auto_encode.
  2. Shape: Does X have the same number of features as training data?
  3. NaN/Inf: Are there missing or infinite values?
  4. Unseen categories: Are there categories in test data not seen during fit?

Constraints

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.