wenmin-wu/ds-skills/anchor-grouped-validation

Claude Code and agent skill by wenmin-wu/ds-skills

Trust tier 2
  • community
LLM review pending
Source check pending

Checking that the SKILL.md file is still in the repository.

Split validation by unique anchor/query entities so no anchor appears in both train and val, preventing data leakage in pairwise matching tasks

Install

npx vskill@latest install wenmin-wu/ds-skills/anchor-grouped-validation

SKILL.md

Anchor-Grouped Validation

Overview

In pairwise matching tasks (phrase similarity, question-answer matching), the same anchor/query maps to multiple targets. If the same anchor appears in both train and validation, the model memorizes anchor-specific patterns rather than learning general similarity. Splitting by unique anchors ensures the model is evaluated on truly unseen queries.

Quick Start

python
import numpy as np
from sklearn.model_selection import StratifiedGroupKFold
groups = df['anchor'].values
scores = (df['score'] * 100).astype(int) # bin for stratification
sgkf = StratifiedGroupKFold(n_splits=4, shuffle=True, random_state=42)
for fold, (train_idx, val_idx) in enumerate(sgkf.split(df, scores, groups)):
train_df = df.iloc[train_idx]
val_df = df.iloc[val_idx]
assert set(train_df['anchor']) & set(val_df['anchor']) == set()

Workflow

  1. Identify the grouping entity (anchor, query, user, document ID)
  2. Use StratifiedGroupKFold for balanced + grouped splits, or manual shuffle-split on unique entities
  3. Verify no group overlap between train and validation sets
  4. Report both in-group (standard) and grouped CV scores — the gap reveals leakage risk

Key Decisions

  • StratifiedGroupKFold vs GroupKFold: stratified variant preserves label distribution across folds
  • Stratification target: bin continuous scores into integers for stratification compatibility
  • Number of folds: 4-5 is standard; fewer folds if number of unique anchors is small
  • Simple alternative: shuffle unique anchors, split first 25% as val, rest as train

References

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewNot runA model review is scheduled for the next rescan.

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
5

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/wenmin-wu/ds-skills/anchor-grouped-validation/badge)](https://verified-skill.com/skills/wenmin-wu/ds-skills/anchor-grouped-validation)

Something wrong with this skill or its page? Tell us.