Agent skill
ce-data-preparation
Validate and preprocess input data for CE pipelines, handle mixed types and categorical features, and configure encoding per ADR-002 and ADR-009.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/ce-data-preparation
SKILL.md
CE Data Preparation
You are helping users prepare their data for use with calibrated-explanations.
Required references
docs/improvement/adrs/ADR-002-validation-and-exception-design.mddocs/improvement/adrs/ADR-009-input-preprocessing-and-mapping-policy.mdsrc/calibrated_explanations/core/validation.pysrc/calibrated_explanations/preprocessing/builtin_encoder.py
Use this skill when
- A user's data has mixed types, NaN values, or categorical features.
- CE raises input validation errors.
- Configuring automatic encoding (
auto_encode='auto'). - Understanding how CE handles feature preprocessing.
- Exporting or importing preprocessing mappings.
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
auto_encode='auto': CE's built-in encoder handles categorical columns deterministically.- Custom preprocessor: Pass your own sklearn transformer via the
preprocessorparameter.
2. Mixed types (DataFrame input)
When passing a DataFrame with mixed dtypes:
- Numeric columns pass through unchanged.
- Non-numeric columns require
auto_encode='auto'or a custom preprocessor. - Without preprocessing, CE raises a
ValidationErrorwith actionable guidance listing the offending columns.
3. Missing values (NaN)
CE does not impute missing values by default:
- Preprocess NaN values before passing to CE.
- The built-in encoder does not handle NaN; use a custom preprocessor with imputation if needed.
4. Unseen categories at inference
Per ADR-009, the unseen_category_policy controls behavior:
"error"(default): RaisesValidationErroron unseen categories."ignore": Maps unseen categories to a sentinel output with a warning.
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:
- Column types: Are all columns numeric? If not, enable
auto_encode. - Shape: Does
Xhave the same number of features as training data? - NaN/Inf: Are there missing or infinite values?
- Unseen categories: Are there categories in test data not seen during fit?
Constraints
- Always fit and calibrate before explaining (CE-first invariant).
- The built-in encoder is deterministic given the same
stable_seed. - Mapping export produces JSON-safe primitives only; no opaque blobs.
- Preprocessing does not change calibration semantics.
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?