agentleFS
imMamdouhaboammarimMamdouhaboammar/matts-skills-into-chatgpt/skills/ml-best-practices/SKILL.md

ml-best-practices

Skill8 starsChanged 2 months agoMITView on GitHub

Statistical machine learning best practices, exploratory data analysis, feature engineering, and rigorous model evaluation. Use when analyzing tabular datasets, engineering features, training classifiers or regressors, forecasting time series, or computing 95% bootstrap confidence intervals — even if they don't explicitly say \"ml best practices\". Do NOT use for standard database queries without ML, basic spreadsheet formatting, or general application backend logic.

We split this skill into the rules it gives an agent

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

  • 0

    Common

    Most of the 4 edited versions we read keep these.

  • 4

    Distinctive

    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:

    Strict Train-Test Isolation: Always partition datasets into training, validation, and test splits before fitting any scalers, encoders, or …

    line 18
  2. Distinctive:

    Dual-Model Benchmark: Never rely on a single model architecture in isolation.

    line 20
  3. Distinctive:

    Story-First Notebook Structure: Every code execution cell must be paired with an analytical markdown cell explaining the observed patterns, …

    line 22
  4. Distinctive:

    Key Point: Check for target column anomalies, extreme outliers, and non-sensical values before modeling.

    line 62

“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “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

Machine Learning Best Practices

Apply rigorous machine learning engineering standards across exploratory analysis, feature engineering, model training, and statistical performance validation.

Core Principle

Every model finding must be grounded in leakage-free splits, dual-model baselines, and statistical confidence intervals.


Core Invariants

  1. Strict Train-Test Isolation: Always partition datasets into training, validation, and test splits before fitting any scalers, encoders, or transformers.
  2. Mandatory Missing Value Strategy: Explicitly quantify missing value frequencies and document domain rationale for keeping, dropping, or imputing them.
  3. Dual-Model Benchmark: Never rely on a single model architecture in isolation. Train at least two distinct candidate families against a naive baseline.
  4. Statistical Significance Over Raw Averages: Report 95% bootstrap confidence intervals for key evaluation metrics (F1, AUC, RMSE) to verify statistical separation.
  5. Story-First Notebook Structure: Every code execution cell must be paired with an analytical markdown cell explaining the observed patterns, trade-offs, and conclusions.

Architecture & Map of Content (MOC)

Raw Dataset & Objective
          │
          ▼
┌────────────────────────────────────────┐
│ 1. Data Hygiene & Anomaly Screening    │ (Missingness, Cardinality, Invariants)
└──────────────────┬─────────────────────┘
                   │
       ┌───────────┴───────────┐
       ▼                       ▼
┌──────────────┐       ┌──────────────┐
│  Clustering  │       │  Forecasting │ (Silhouette Optimization, Stationarity)
└──────────────┘       └──────────────┘
       │                       │
       └───────────┬───────────┘
                   │
       ┌───────────┴───────────┐
       ▼                       ▼
┌──────────────┐       ┌──────────────┐
│Classification│       │  Regression  │ (Pipeline Encoders, Regularization)
└──────────────┘       └──────────────┘
                   │
                   ▼
┌────────────────────────────────────────┐
│ 2. Statistical Model Comparison        │ (95% Bootstrap CIs, Slice Analysis)
└────────────────────────────────────────┘

Step-by-Step Procedure (TWI)

Step 1: Exploratory Analysis & Anomaly Detection

  • Action: Inspect schema, compute summary statistics, and visualize target distributions with scatter plots and histograms.
  • Key Point: Check for target column anomalies, extreme outliers, and non-sensical values before modeling.
  • Why: Training models on corrupt or undetected anomalous targets invalidates the experimental setup.

Step 2: Supervised Modeling (Classification / Regression)

  • Action: Apply transformers inside scikit-learn pipelines fit exclusively on training data; evaluate regularization to control overfitting.
  • Key Point: For high-cardinality nominal features, restrict cardinality or use target encoding with out-of-fold regularization.
  • Why: Fitting transformers on the combined dataset causes subtle target and variance leakage.
  • Inline Checklist:
    • Data split chronologically (if temporal) or via StratifiedKFold (if classification)
    • Encoders and scalers wrapped inside Pipeline, fitted only on X_train
    • Confusion matrices, ROC curves, or residual diagnostic plots generated
    • Missing values handled with documented justification

Step 3: Unsupervised Clustering & Time-Series Forecasting

  • Action: For clustering, standardize features and optimize the Silhouette Score; for forecasting, test stationarity and seasonality.
  • Key Point: For time series, verify that no future information leaks into historical lag features.
  • Why: Silhouette optimization prevents arbitrary cluster count selection; stationarity testing determines appropriate model family.

Step 4: Model Comparison & 95% Bootstrap Confidence Intervals

  • Action: Benchmark multiple model candidates on identical cross-validation folds and calculate bootstrap confidence intervals.
  • Key Point: Conduct slice-based error analysis across critical subpopulations and compile an operational trade-off table.
  • Why: Point estimates of accuracy often conceal performance drops on key customer cohorts.

Anti-Rationalization Guardrails

Tempting RationalizationBinding RuleEngineering Rationale
"Standard scaling before splitting is harmless."Fit scalers strictly on training folds.Scalers compute dataset-wide statistics that cause subtle distribution leakage.
"Accuracy is 94%, so the classifier is ready."Always inspect PR-AUC, F1, and confusion matrix.On imbalanced classes, 94% accuracy may be worse than a naive majority-class guess.
"We don't need a baseline because XGBoost is superior."Always establish naive and linear baselines first.Naive baselines justify model complexity and reveal genuine signal gains.
"Shuffling temporal data is fine if well-mixed."Split temporal data chronologically.Shuffling time series causes future lookahead leakage into historical folds.

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.