Sign in Get 3 free credits

Try a job or a niche: tiktok captions, study notes, excel formulas. Press Esc to close.

Leak Free ML Features

Keeps machine learning features and data splits free of leakage, so offline scores hold up in production.

Claude's review

7/10 Concrete leakage prevention: pipeline fitting, merge_asof point-in-time joins, closed-left rolling windows, group CV and shuffled-label guard tests.

We asked Claude the question you would ask: would I be glad I installed this? Two separate reviews, the second blind to the first, must both rate a skill 7 or higher before we sell it.

In detail

Use when building or changing features, preprocessing, encoders, resampling or train/validation/test splits — keep every fitted transform inside a Pipeline fitted on training folds only, and build time and group features without seeing the future or the same entity twice

How you use it

  1. Add it to your pack, then download your pack (1 credit).
  2. In Claude, open Customize > Skills and upload the zip. Code execution needs to be on under Settings > Capabilities.
  3. Ask Claude for the job in your own words. It uses the skill when your request matches what it does. Step by step guide

Safety check

Nothing risky found: no hidden instructions, no download and run, no reading of saved passwords or keys.

An automated scan lowers risk but cannot promise zero risk. How we check skills

Preview

The first lines of SKILL.md
---
name: leakage-safe-feature-engineering
category: ml
description: Use when building or changing features, preprocessing, encoders, resampling or train/validation/test splits — keep every fitted transform inside a Pipeline fitted on training folds only, and build time and group features without seeing the future or the same entity twice
tech_stack: Python
source: original; informed by scikit-learn Common pitfalls and recommended practices and the cross-validation user guide (cited, not reproduced)
---
# 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

```python
# ❌ 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.
...

From makifbaysal's repository, Apache-2.0 licence.

Related skills

  • Checked

    dbt platform migration

    Moves a dbt project from one warehouse to another and fixes SQL dialect gaps, so your models build again.

    by dbt-labs 777
    7/101 credit
  • Checked

    CSV and Excel merging

    Merges, stacks and dedupes CSV and Excel files into one clean table, then checks the row counts add up.

    by OneWave-AI 454
    7/101 credit
  • Checked

    BigQuery migration checks

    Validates that tables moved to BigQuery match their source on schema, aggregates and rows, so nothing is lost.

    by google 25k
    7/101 credit
  • Checked

    dbt Mesh contracts

    Checks whether a dbt model change breaks consumers and versions it, so downstream dashboards keep working.

    by dbt-labs 777
    7/101 credit
  • Checked

    SQL and dbt Analytics

    Writes analytical SQL and dbt models tested for grain and join errors, so the numbers come out right.

    by makifbaysal 123
    7/101 credit
  • Checked

    D3 Animated Data Charts

    Turns sourced data into honest, accessible animated D3 charts that render reliably frame by frame for video.

    by calesthio 262
    7/101 credit

Secure checkout

Credits

AUD

  1. 1Choose
  2. 2Pay on Square
  3. 3Credits added