dataset-splitting
Create reproducible train/validation/test splits with stratification, leakage prevention, and distribution validation.
Skill by mkurman
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/mkurman-dataset-splitting-2006ad
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: testing, research
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions: not checked yet.
What's inside
- Skill name
dataset-splitting- Description
- Create reproducible train/validation/test splits with stratification, leakage prevention, and distribution validation. Covers random, stratified, grouped, and time-series split strategies.
- License
- MIT
- Instructions
- 146 lines in SKILL.md · view on GitHub
Files (1)
- SKILL.md
SKILL.md (first lines)
# Dataset Splitting
## Overview
Train/validation/test splits are the single most important guardrail against overfitting and data leakage. A bad split invalidates everything downstream. Split once, lock the split, and never let test data influence any decision.
## When to Use
Use this skill when:
- Preparing data for supervised learning.
- Designing evaluation protocols for model comparison.
- Setting up cross-validation folds.
- Ensuring no data leakage between splits.
Do not use for:
- Unsupervised learning evaluation — different rules apply.
- Time-series forecasting with backtesting — use `darts` or `prophet` skills.
- Data cleaning — use `dataset-cleaning` before splitting.
## Split Strategies
### 1. Standard Random Split (IID)
```python
from sklearn.model_selection import train_test_split
# Single split (fixed seed, stratified)
X_train, X_test, y_train, y_test = train_test_split(
X, y,
test_size=0.2,
stratify=y,
random_state=42 # NEVER change this casually
)
# Train / validation / test (two-step)
X_temp, X_test, y_temp, y_test = train_test_split(
X, y, test_size=0.15, stratify=y, random_state=42
)
X_train, X_val, y_train, y_val = train_test_split(
X_temp, y_temp, test_size=0.1765, stratify=y_temp, random_state=42
)
# Result: 70% train, 15% val, 15% test
```
### 2. Stratified Split (Class Imbalance)
```python
# Stratify on target AND protected attributes
X_train, X_test, y_train, y_test = train_test_split(
X, y,
test_size=0.2,
stratify=df[['target', 'gender', 'region']].apply(tuple, axis=1),
random_state=42
)
```
### 3. Group-Level Split (No Cross-Contamination)
```python
from sklearn.model_selection import GroupShuffleSplit
# When rows from the same group MUST stay together
# Example: multiple samples per patient
gss = GroupShuffleSplit(n_splits=1, test_size=0.2, random_state=42)
train_idx, test_idx = next(gss.split(X, y, groups=df['patient_id']))
X_train, X_test = X.iloc[train_idx], X.iloc[test_idx]
```
### 4. Time-Series Split (No Future Leakage)
```python
# Chronological split — NEVER shuffle time data
df = df.sort_values('timestamp')
split_idx = int(len(df) * 0.8)
train = df.iloc[:split_idx]
test = df.iloc[split_idx:]
# For multiple backtest windows:
from sklearn.model_selection import TimeSeriesSplit
tscv = TimeSeriesSplit(n_splits=5)
for train_idx, test_idx in tscv.split(X):
X_train, X_test = X.iloc[train_idx], X.iloc[test_idx]
# Each fold uses older data for training, newer for testing
```
## Cross-Validation Setup
```python
from sklearn.model_selection import StratifiedKFold, RepeatedStratifiedKFold
# Standard 5-fold
cv = StratifiedKFold(n_splits=5, shuffle=True, random_state=42)
# Repeated for small datasets
cv = RepeatedStratifiedKFold(n_splits=5, n_repeats=3, random_state=42)
```
## Leakage Prevention Checklist
Before locking the split, verify:
1. **No ID leakage**: same entity does not appear in train and test.
2. **No temporal leakage**: all train timestamps precede all test timestamps.
3. **No target leakage**: no feature derived from test data (including imputation, scaling, encoding).
4. **No group leakage**: groups (patients, users, experiments) are fully in one split.
5. **Stratification preserved**: target distribution similar across splits.
```python
# Split distribution validation
for split_name, split_df in [('train', train_df), ('val', val_df), ('test', test_df)]:
print(f"{split_name}: {split_df['target'].value_counts(normalize=True).to_dict()}")
# Group integrity check
train_groups = set(train_df['group_id'])
test_groups = set(test_df['group_id'])
assert len(train_groups & test_groups) == 0, "Group leakage detected!"
```
## Locking the SplitFrom mkurman/zorai, MIT.
More from mkurman/zorai
- 0.798score
best-practices
web-quality-skills
Apply modern web development best practices for security, compatibility, and code quality.
SkillAFreshness: A★ 325Claude Code +9 - 0.597score
video-analyzer
mkurman
Use this skill when analyzing existing video files using FFmpeg and AI vision, extracting frames for design system generation, detecting scene boundaries…
SkillAFreshness: A★ 325Claude Code +9 - 0.597score
internal-docs
mkurman
Use this skill when writing, reviewing, or improving internal engineering documents - RFCs, design docs, post-mortems, runbooks, and knowledge base articles.
SkillAFreshness: A★ 325Claude Code +9 - 0.597score
proposal-writing
mkurman
Use this skill when writing proposals, responding to RFPs, drafting SOWs, or developing pricing strategies.
SkillAFreshness: A★ 325Claude Code +9 - 0.597score
budgeting-planning
mkurman
Use this skill when building budgets, conducting variance analysis, implementing rolling forecasts, or allocating costs.
SkillAFreshness: A★ 325Claude Code +9 - 0.597score
create-workflow
mkurman
Conversational guide for creating valid YAML workflow definitions.
SkillAFreshness: A★ 325Claude Code +9 - 0.597score
product-strategy
mkurman
Use this skill when defining product vision, building roadmaps, prioritizing features, or choosing frameworks like RICE, ICE, or MoSCoW.
SkillAFreshness: A★ 325Claude Code +9 - 0.597score
brand-strategy
mkurman
Use this skill when defining brand positioning, voice and tone guidelines, brand architecture, or storytelling frameworks.
SkillAFreshness: A★ 325Claude Code +9 - 0.597score
social-media-strategy
mkurman
Use this skill when planning social media strategy, creating platform-specific content, scheduling posts, or analyzing engagement metrics.
SkillAFreshness: A★ 325Claude Code +9 - 0.597score
compensation-strategy
mkurman
Use this skill when benchmarking compensation, designing equity plans, building leveling frameworks, or structuring total rewards.
SkillAFreshness: A★ 325Claude Code +9 - 0.597score
account-management
mkurman
Use this skill when managing key accounts, planning expansions, running QBRs, or mapping stakeholders.
SkillAFreshness: A★ 325Claude Code +9 - 0.597score
video-audio-design
mkurman
Use this skill when adding audio to programmatic videos - generating narration with ElevenLabs TTS, sourcing royalty-free background music, creating SFX with…
SkillAFreshness: A★ 325Claude Code +9
Signals
- Stars
- 325
- Forks
- 24
- Open issues
- 0
- Last commit (this folder)
- May 12, 2026 (5 months ago)
- Last release
- Oct 23, 2026 (6 days ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/mkurman/zorai
- Website
- zorai.app/
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
Same skill elsewhere
Copies of this SKILL.md published by others; search shows only one of them.
- 0.590score
dataset-splitting
mkurman
Create reproducible train/validation/test splits with stratification, leakage prevention, and distribution validation.
SkillAFreshness: A★ 325Claude Code +9 - 0.308score
dataset-splitting
mkurman
Create reproducible train/validation/test splits with stratification, leakage prevention, and distribution validation.
SkillAFreshness: A★ 325Claude Code +9
More from mkurman
- 0.597score
compensation-strategy
mkurman
Use this skill when benchmarking compensation, designing equity plans, building leveling frameworks, or structuring total rewards.
SkillAFreshness: A★ 325Claude Code +9 - 0.597score
account-management
mkurman
Use this skill when managing key accounts, planning expansions, running QBRs, or mapping stakeholders.
SkillAFreshness: A★ 325Claude Code +9 - 0.597score
brand-strategy
mkurman
Use this skill when defining brand positioning, voice and tone guidelines, brand architecture, or storytelling frameworks.
SkillAFreshness: A★ 325Claude Code +9 - 0.597score
budgeting-planning
mkurman
Use this skill when building budgets, conducting variance analysis, implementing rolling forecasts, or allocating costs.
SkillAFreshness: A★ 325Claude Code +9 - 0.597score
create-workflow
mkurman
Conversational guide for creating valid YAML workflow definitions.
SkillAFreshness: A★ 325Claude Code +9 - 0.597score
internal-docs
mkurman
Use this skill when writing, reviewing, or improving internal engineering documents - RFCs, design docs, post-mortems, runbooks, and knowledge base articles.
SkillAFreshness: A★ 325Claude Code +9
Cite this page
dataset-splitting skill. Agent Mart. https://agentmart.dev/skills/mkurman-dataset-splitting-2006ad (last updated 2026-10-24)