imbalanced-data

imbalanced-data is a skill for Claude Code, Codex from param087/agent-ml-skills. It costs 49 tokens per session (835 once invoked), scanned A, original, MIT.

A guide for machine-learning problems where the target outcome is rare, such as fraud, disease, churn, or anomalies.

In plain words
What is it for?
It helps choose suitable metrics, apply SMOTE or undersampling, set class weights, tune prediction thresholds, and evaluate imbalanced data correctly.
Why use it?
It prevents misleading accuracy results and covers metrics, class weighting, resampling, and decision-threshold selection while avoiding data leakage.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit It helps choose suitable metrics, apply SMOTE or undersampling, set class weights, tune prediction thresholds, and evaluate imbalanced data correctly.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/param087/agent-ml-skills/imbalanced-data
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add param087/agent-ml-skills --skill imbalanced-data
Clone the repo
git clone --depth 1 https://github.com/param087/agent-ml-skills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for imbalanced-data

README.md
[![agentmods](https://agentmods.dev/badge/skills/param087/agent-ml-skills/imbalanced-data/github.svg)](https://agentmods.dev/skills/param087/agent-ml-skills/imbalanced-data)
Your own site
<a href="https://agentmods.dev/skills/param087/agent-ml-skills/imbalanced-data"><img src="https://agentmods.dev/badge/skills/param087/agent-ml-skills/imbalanced-data/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for imbalanced-data

Your own site · 80×15
<a href="https://agentmods.dev/skills/param087/agent-ml-skills/imbalanced-data"><img src="https://agentmods.dev/badge/skills/param087/agent-ml-skills/imbalanced-data.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 49 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 835 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00049 $0.00835
Opus 5.5 $0.00020 $0.00334
Sonnet 5.5 $0.00010 $0.00167
Haiku 4.5 $0.00005 $0.00084

Measured 2mo ago against content hash 3519cb001105, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

imbalanced-data scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/imbalanced-data/SKILL.md · 86 lines

How it starts

The opening of the file, as written. The whole thing — 86 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Imbalanced Data

Overview

When positives are rare, naive training and naive metrics both mislead. A model that always predicts "negative" can score 99% accuracy and catch zero fraud. Handle imbalance at three levels: metric, algorithm, and threshold — and resample inside cross-validation, never before.

When to use

  • Class ratio is skewed (e.g., 95/5 or worse).
  • Catching the rare class matters (fraud, defaults, rare disease, defects).

Step 1 — Fix the metric first

Drop accuracy and ROC-AUC-as-sole-metric. Prefer:

  • PR-AUC (average precision) — most informative for rare positives.
  • Recall @ fixed precision — "catch X% of fraud while keeping false alarms tolerable."
  • F1 / Fβ — β>1 weights recall when misses are costly.

Step 2 — Algorithm-level handling

Technique How When
Class weights class_weight="balanced" / scale_pos_weight First choice — no data duplication
Undersample majority RandomUnderSampler Lots of data, majority redundant
Oversample minority SMOTE / ADASYN Limited minority samples
Combine SMOTE + Tomek/ENN Noisy boundaries

Class weights are the cheapest, leak-free first move:

# sklearn
LogisticRegression(class_weight="balanced")
# XGBoost / LightGBM
scale_pos_weight = n_negative / n_positive

Step 3 — Resample INSIDE the pipeline (no leakage)

Resampling before CV leaks synthetic neighbors across the split and inflates scores. Use imblearn's pipeline so SMOTE fits on training folds only:

from imblearn.pipeline import Pipeline as ImbPipeline
from imblearn.over_sampling import SMOTE
from sklearn.ensemble import HistGradientBoostingClassifier
from sklearn.model_selection import cross_val_score, StratifiedKFold

pipe = ImbPipeline([
    ("smote", SMOTE(random_state=42)),   # applied to train fold only
    ("clf", HistGradientBoostingClassifier(random_state=42)),
])
cv = StratifiedKFold(5, shuffle=True, random_state=42)
print(cross_val_score(pipe, X, y, cv=cv, scoring="average_precision").mean())

Read the full file on GitHub · 86 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2mo ago First seen · 86 lines · 49 tokens per session scan A 3519cb001105

Subscribe to this mod's changes

imbalanced-data is a skill published in the GitHub repository param087/agent-ml-skills (13 stars, last pushed 5mo ago), licensed MIT. It adds 49 tokens to every session and 835 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

imbalanced-data compared with skills from other repositories

imbalanced-data next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
imbalanced-dataparam087/agent-ml-skillsSkill135mo agoMITA49Claude Code, Codex
spark-training-gotchaswshobson/agentsSkill42kyesterdayMITA63Claude Code
9router-sttdecolua/9routerSkill32k9d agoMITA63Claude Code, Codex
9routerdecolua/9routerSkill32k9d agoMITA84Claude Code, Codex
9router-embeddingsdecolua/9routerSkill32k9d agoMITA66Claude Code, Codex
dashscopecalesthio/OpenMontageSkill77k3d agoAGPL-3.0A93Claude Code, Codex
ultralytics-platformfcakyon/claude-codex-settingsSkill1.2kyesterdayApache-2.0A135Claude Code