scikit-learn-python

Guides writing, reviewing, and verifying scikit-learn pipelines, splitters, and model evaluation workflows.

Updated Aug 12, 2026
One-click install
npx skills add https://github.com/schattenspiegel/skill-foundry-skills --skill scikit-learn-python-schattenspiegel
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: scikit-learn-python
Source: https://github.com/schattenspiegel/skill-foundry-skills/tree/main/skills/scikit-learn-python
Command: npx skills add https://github.com/schattenspiegel/skill-foundry-skills --skill scikit-learn-python-schattenspiegel

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires scikit-learn, numpy, pandas, pytest, and includes references (resource) components.

What problem does it solve? Machine-learning code often fails silently through preprocessing leakage, wrong cross-validation splitters, or drifted inference schemas. This Skill enforces explicit contracts for scikit-learn estimators, pipelines, splitters, and scorers so models are trained, evaluated, and deployed without hidden data leakage or contract violations. ## Core Features & Use Cases - Leakage-safe pipelines: Cross-validate preprocessing and classification as one cloneable unit so transformers never see validation data. - Group-aware splitting: Use GroupKFold with disjointness verification to prevent entity leakage across folds. - Inference schema guards: Reject drifted feature columns, duplicate names, and unexpected class mappings at prediction time. - Use Case: You are reviewing a teammate's training script and suspect the scaler was fit before the train/test split. Use this Skill to restructure the code into a Pipeline, pick the correct splitter, and add deterministic tests proving no leakage. ## Quick Start Ask the AI to review your scikit-learn training script for preprocessing leakage and rewrite it as a cross-validated Pipeline with the correct splitter and verification tests.

Frequently Asked Questions about scikit-learn-python

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent data leakage in scikit-learn cross-validation?▼

Place every data-dependent preprocessing step inside a Pipeline or ColumnTransformer so cross-validation clones and fits the whole unit per split. Never fit transformers on the full dataset before splitting, and keep the test set outside model selection.

How do I choose between KFold, StratifiedKFold, and GroupKFold?▼

Choose the splitter from the data-generating process: StratifiedKFold for class balance, GroupKFold when rows share an entity that must not span folds, and a time-ordered splitter for temporal data. Random splitting is not a neutral default.

When should I not use scikit-learn for a machine-learning task?▼

Avoid scikit-learn for PyTorch or JAX training loops, statistical inference, and generic NumPy calculations. It targets estimator-based workflows with fit, transform, predict, and pipeline composition rather than custom gradient-based training.

How do I validate feature schemas at inference time in scikit-learn?▼

Compare incoming DataFrame columns against model.feature_names_in_ for exact order and uniqueness, and check model.classes_ against the expected positive-class contract. Raise a precise ValueError on any drift instead of coercing inputs.

Why does setting random_state not guarantee reliable model evaluation?▼

random_state makes stochastic estimators and splitters repeatable, but repeatability is not uncertainty estimation. You still need per-split score inspection, variance reporting, and task-appropriate metrics with stated averaging and threshold policy.