agentleFS
HarrypatriaHarrypatria/data-mining-ml/skills/data-preparation/SKILL.md

data-preparation

Skill2 starsChanged 12 days agoMITView on GitHub

Data Preparation. Clean, join and split data without leakage - data cleaning, joins and merges with row-count checks, deduplication, missing value imputation, type fixes, outlier handling, train test split, validation split, cross-validation folds, stratified, group-aware and time-series (forward-chaining) splits, scikit-learn Pipeline and ColumnTransformer. Use for data wrangling, preprocessing, data cleaning, ETL for machine learning, or any request to prepare data for a model. CRISP-DM Data Preparation.

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 4 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Every transformation is either a deterministic cleaning step (applied once, before splitting, with no learned statistics) or a learned step …

    line 8
  2. Distinctive:

    Document: every transformation in the feature dictionary: what, why, and when the input is available.

    line 25
  3. Distinctive:

    Never fill with a statistic computed on the full frame before splitting.

    line 36
  4. Distinctive:

    No column recorded after the prediction time.

    line 46

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Data Preparation

Every transformation is either a deterministic cleaning step (applied once, before splitting, with no learned statistics) or a learned step (fitted inside the pipeline on training folds only). Mixing them up is the most common leak.

Order of work

  1. Deterministic cleaning, before the split. Fix types, parse dates, standardize units and category spellings, remove exact duplicates, drop rows with an invalid target, remove post-event columns. Print the row count after each step.
  2. Joins with assertions.
    n = len(left)
    out = left.merge(right, on="customer_id", how="left", validate="many_to_one")
    assert len(out) == n, f"join changed rows: {n} -> {len(out)}"
  3. Choose the split from the data (references/split-strategies.md):
    • Independent rows, classification: stratified.
    • Repeated entities: group-aware (GroupKFold, StratifiedGroupKFold, GroupShuffleSplit).
    • Time-ordered data: forward-chaining (TimeSeriesSplit or a cutoff date), with a gap equal to the label horizon. Fix and record the seed. Hold out the test set now; it is touched once, at evaluation.
  4. Learned steps inside the pipeline. Imputers, scalers, encoders, winsorizers, selectors, resamplers and target encoders go into a ColumnTransformer and Pipeline (or an imbalanced-learn Pipeline when resampling). Fit happens on training folds only, through cross-validation or one fit on the training split.
  5. Document every transformation in the feature dictionary: what, why, and when the input is available.

Missing values

MechanismDefault
MCAR, small shareSimpleImputer(strategy="median")
MARIterativeImputer or KNNImputer inside the pipeline
MNAR or informativeImputer with add_indicator=True; state the assumption
Inference (statistics, not prediction)Multiple imputation, pooled estimates

Never fill with a statistic computed on the full frame before splitting.

Outliers

Decide error or signal first. Errors are fixed or removed with a written rule and a count. Signal is kept and handled with robust scaling, winsorizing inside the pipeline, or robust losses.

Checks before modeling

  • X_train.shape, X_test.shape, positive counts per split, no shared entity ids across splits.
  • df.duplicated().sum() before splitting is zero or explained.
  • No column recorded after the prediction time.
  • The pipeline object prints cleanly and pipeline.fit(X_train, y_train) runs.

Conditions that change preparation (skew, zero inflation, high cardinality, drift): data-profiling/references/scenarios.md.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.