leakage-safe-feature-engineering

leakage-safe-feature-engineering is a skill for Claude Code, Codex from makifbaysal/tasktrooper. It costs 57 tokens per session (1,706 once invoked), scanned A, original, Apache-2.0.

Guidance for creating machine-learning features and data preparation without letting training data reveal information from the future or from the rows being tested. It covers preprocessing, encoders, resampling, and train, validation, and test splits inside a reusable pipeline.

In plain words
What is it for?
Use it when building or changing features, preprocessing, encoders, sampling, or data splits. It helps keep learned transformations inside a pipeline fitted only on the appropriate training data.
Why use it?
Data leakage can produce an excellent test score while the model fails on real predictions. It prevents transforms from learning from test rows, future events, or the same entity appearing on both sides of a split.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when building or changing features, preprocessing, encoders, sampling, or data splits. It helps keep learned transformations inside a pipeline fitted only on the appropriate training data.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/makifbaysal/tasktrooper/leakage-safe-feature-engineering
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add makifbaysal/tasktrooper --skill leakage-safe-feature-engineering
Clone the repo
git clone --depth 1 https://github.com/makifbaysal/tasktrooper

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for leakage-safe-feature-engineering

README.md
[![agentmods](https://agentmods.dev/badge/skills/makifbaysal/tasktrooper/leakage-safe-feature-engineering/github.svg)](https://agentmods.dev/skills/makifbaysal/tasktrooper/leakage-safe-feature-engineering)
Your own site
<a href="https://agentmods.dev/skills/makifbaysal/tasktrooper/leakage-safe-feature-engineering"><img src="https://agentmods.dev/badge/skills/makifbaysal/tasktrooper/leakage-safe-feature-engineering/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for leakage-safe-feature-engineering

Your own site · 80×15
<a href="https://agentmods.dev/skills/makifbaysal/tasktrooper/leakage-safe-feature-engineering"><img src="https://agentmods.dev/badge/skills/makifbaysal/tasktrooper/leakage-safe-feature-engineering.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 57 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,706 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00057 $0.01706
Opus 5.5 $0.00023 $0.00682
Sonnet 5.5 $0.00011 $0.00341
Haiku 4.5 $0.00006 $0.00171

Measured 4d ago against content hash bb3e9ba1d8a5, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

leakage-safe-feature-engineering scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

catalog/agents/data-scientist/skills/leakage-safe-feature-engineering/SKILL.md · 143 lines

How it starts

The opening of the file, as written. The whole thing — 143 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Leakage-Safe Feature Engineering

Overview

Leakage is information in training that will not exist at prediction time. It produces a great offline score and a model that fails in production — and no test fails, because the code does exactly what it was told. The three sources: transforms fitted on rows they later score, features computed from the future, and the same entity on both sides of a split.

Core principle: split first; everything that learns from data (scalers, imputers, encoders, selectors, resamplers) is fitted inside the training fold only — in practice, inside one scikit-learn Pipeline that is cross-validated and shipped as a single artifact.

1. Fit inside the Pipeline, never before the split

# ❌ the scaler and the selector have seen the test rows
X_scaled = StandardScaler().fit_transform(X)
X_sel = SelectKBest(k=20).fit_transform(X_scaled, y)
X_train, X_test, y_train, y_test = train_test_split(X_sel, y)

# ✅ split once, then everything learned lives in the pipeline
X_train, X_test, y_train, y_test = train_test_split(
    X, y, test_size=0.2, stratify=y, random_state=seed
)
preprocess = ColumnTransformer([
    ("num", make_pipeline(SimpleImputer(strategy="median"), StandardScaler()), numeric_cols),
    ("cat", OneHotEncoder(handle_unknown="ignore", min_frequency=20), categorical_cols),
])
model = make_pipeline(preprocess, SelectKBest(k=20), LogisticRegression(max_iter=1000))
scores = cross_validate(model, X_train, y_train, cv=cv, scoring="average_precision")

cross_validate refits the whole pipeline per fold, so imputation medians, category vocabularies and selected features are learned from that fold's training part only. Use set_output(transform="pandas") when you need column names downstream.

2. Encoders and resampling

  • Target encoding: scikit-learn's TargetEncoder.fit_transform uses internal cross-fitting; fit(X, y).transform(X) on the same rows does not and leaks the target. Inside a Pipeline, fit calls fit_transform, which is the safe path. Never compute per-category target means with a groupby over the full table.
  • Frequency/count encoding, aggregates, PCA, clustering features: fitted transforms like any other — inside the pipeline.
  • Class imbalance: prefer class_weight="balanced" or threshold tuning. Oversampling (SMOTE) goes inside an imblearn.pipeline.Pipeline only if the repository already depends on imbalanced-learn; oversampling before the split copies near-identical rows into validation.

Read the full file on GitHub · 143 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 143 lines · 57 tokens per session scan A bb3e9ba1d8a5

Subscribe to this mod's changes

leakage-safe-feature-engineering is a skill published in the GitHub repository makifbaysal/tasktrooper (113 stars, last pushed yesterday), licensed Apache-2.0. It adds 57 tokens to every session and 1,706 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-10-09.