ml-antipattern-validator
Prevents 30+ critical AI/ML mistakes including data leakage, evaluation errors, training pitfalls, and deployment issues. Use when working with ML training, testing, model evaluation, or deployment.
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o ml-antipattern-validator.zip https://jpskill.com/download/18878.zip && unzip -o ml-antipattern-validator.zip && rm ml-antipattern-validator.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/18878.zip -OutFile "$d\ml-antipattern-validator.zip"; Expand-Archive "$d\ml-antipattern-validator.zip" -DestinationPath $d -Force; ri "$d\ml-antipattern-validator.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
ml-antipattern-validator.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
ml-antipattern-validatorフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 7
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
[Skill 名] ml-antipattern-validator
MLアンチパターンバリデーター
概要
AI/ML開発における30以上のアンチパターンを検知し、防止するスキルです。
主要原則: 印象的なメトリクスよりも正直な評価。
アクティベートするタイミング
自動トリガー:
- MLトレーニングコード (
train*.py、モデルトレーニング) - データセットの準備または分割
- モデルの評価またはテスト
- 本番環境へのデプロイ計画
手動トリガー:
@validate-ml- 完全な検証@check-leakage- データリークの検出@verify-eval- 評価方法論の検証
実装前チェックリスト
✅ 要件:
□ 問題が成功指標とともに明確に定義されている
□ 訓練/テスト分割戦略が定義されている
□ 評価方法論がビジネス目標と一致している
✅ データ整合性:
□ 時間的リークがない(未来 → 過去)
□ ターゲットリークがない(特徴量に答えが含まれている)
□ 前処理リークがない(全データでfitしている)
□ グループリークがない(関連するサンプルが分割されている)
✅ 評価設定:
□ テストセットが完全にホールドアウトされている
□ メトリクスがビジネス目標と一致している
□ ベースラインモデルが定義されている
重要なアンチパターン
カテゴリ1: データリーク 🚨
1.1 ターゲットリーク
❌ 誤り: "refund_issued" を使って "purchase_fraud" を予測する
✅ 正しい: 購入時に利用可能な特徴量のみを使用する
1.2 時間的リーク
❌ 誤り: train = df[df['date'] > '2024-06-01'] # 未来のデータ
✅ 正しい: train = df[df['date'] < '2024-06-01'] # 訓練には過去のデータ
1.3 前処理リーク
❌ 誤り: X_scaled = scaler.fit_transform(X); train_test_split(X_scaled)
✅ 正しい: まず分割し、その後 scaler.fit(X_train)
1.4 グループリーク
❌ 誤り: train_test_split(df) # 同じユーザーが両方のセットにいる
✅ 正しい: GroupShuffleSplit(groups=df['user_id'])
1.5 データ拡張リーク
❌ 誤り: augment(X) → train_test_split()
✅ 正しい: train_test_split() → augment(X_train)
カテゴリ2: 評価の誤り ⚠️
2.1 訓練データでのテスト
❌ 誤り: evaluate(model, training_data)
✅ 正しい: evaluate(model, unseen_test_data)
2.2 メトリクスの不一致
ビジネス目標 → 適切なメトリクス:
- ランキング → NDCG, MRR, MAP
- 不均衡データ → F1, Precision@K, AUC-PR
- 均衡データ → Accuracy, AUC-ROC
2.3 精度パラドックス
❌ 誤り: 99:1の不均衡データで99%の精度
✅ 正しい: classification_report()でクラスごとのメトリクスを確認する
2.4 無効な時系列CV
❌ 誤り: cross_val_score(model, X, y, cv=5) # 時間をシャッフルしてしまう!
✅ 正しい: TimeSeriesSplit(n_splits=5)
2.5 テストセットでのハイパーパラメータチューニング
❌ 誤り: grid_search(model, X_test, y_test)
✅ 正しい: 訓練/検証/テストの3分割
カテゴリ3: 訓練の落とし穴 🔧
3.1 バッチ正規化推論エラー
❌ 誤り: predictions = model(X_test) # まだ訓練モード
✅ 正しい: model.eval(); with torch.no_grad(): predictions = model(X_test)
3.2 早期停止の過学習
❌ 誤り: EarlyStopping(patience=50)
✅ 正しい: EarlyStopping(patience=5, min_delta=0.001, restore_best_weights=True)
3.3 学習率ウォームアップ
✅ 正しい: get_linear_schedule_with_warmup(num_warmup_steps=1000)
3.4 クラス不均衡
❌ 誤り: CrossEntropyLoss() # 多数派に偏る
✅ 正しい: CrossEntropyLoss(weight=class_weights)
検出パターン
リーク検出
# 特徴量とターゲットの相関をチェック
correlation = df[features].corrwith(df['target'])
if (correlation.abs() > 0.95).any():
raise DataLeakageError("Suspiciously high correlation")
# 時間的順序をチェック
if train['date'].min() > test['date'].max():
raise TemporalLeakageError("Training on future, testing on past")
# グループの重複をチェック
if train_groups & test_groups:
raise GroupLeakageError("Overlapping groups")
モードチェック
if model.training:
raise InferenceModeError("Model in training mode during evaluation")
検証チェックリスト
デプロイ前:
- [ ] データリークが検出されていない
- [ ] テストセットが訓練中に一度も参照されていない
- [ ] メトリクスがビジネス目標と一致している
- [ ] 推論のために model.eval() が呼び出されている
- [ ] クラス不均衡が処理されている
- [ ] 共変量シフトの監視が計画されている
参考文献
詳細な例とシナリオについては、references/REFERENCE.md を参照してください。
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
ML Antipattern Validator
Overview
AI/ML 개발에서 30+ 안티패턴을 감지하고 방지하는 스킬입니다.
Key Principle: Honest evaluation > Impressive metrics.
When to Activate
Automatic Triggers:
- ML training code (
train*.py, model training) - Dataset preparation or splitting
- Model evaluation or testing
- Production deployment planning
Manual Triggers:
@validate-ml- Full validation@check-leakage- Data leakage detection@verify-eval- Evaluation methodology
Pre-Implementation Checklist
✅ Requirements:
□ Problem clearly defined with success metrics
□ Train/test split strategy defined
□ Evaluation methodology matches business objective
✅ Data Integrity:
□ No temporal leakage (future → past)
□ No target leakage (answer in features)
□ No preprocessing leakage (fit on all data)
□ No group leakage (related samples split)
✅ Evaluation Setup:
□ Test set completely held out
□ Metrics aligned with business objective
□ Baseline models defined
Critical Antipatterns
Category 1: Data Leakage 🚨
1.1 Target Leakage
❌ WRONG: Using "refund_issued" to predict "purchase_fraud"
✅ CORRECT: Only use features available at purchase time
1.2 Temporal Leakage
❌ WRONG: train = df[df['date'] > '2024-06-01'] # Future data
✅ CORRECT: train = df[df['date'] < '2024-06-01'] # Past for training
1.3 Preprocessing Leakage
❌ WRONG: X_scaled = scaler.fit_transform(X); train_test_split(X_scaled)
✅ CORRECT: Split first, then scaler.fit(X_train)
1.4 Group Leakage
❌ WRONG: train_test_split(df) # Same user in both sets
✅ CORRECT: GroupShuffleSplit(groups=df['user_id'])
1.5 Data Augmentation Leakage
❌ WRONG: augment(X) → train_test_split()
✅ CORRECT: train_test_split() → augment(X_train)
Category 2: Evaluation Mistakes ⚠️
2.1 Testing on Training Data
❌ WRONG: evaluate(model, training_data)
✅ CORRECT: evaluate(model, unseen_test_data)
2.2 Metric Misalignment
Business Objective → Appropriate Metric:
- Ranking → NDCG, MRR, MAP
- Imbalanced → F1, Precision@K, AUC-PR
- Balanced → Accuracy, AUC-ROC
2.3 Accuracy Paradox
❌ WRONG: 99% accuracy on 99:1 imbalanced data
✅ CORRECT: Check per-class metrics with classification_report()
2.4 Invalid Time Series CV
❌ WRONG: cross_val_score(model, X, y, cv=5) # Shuffles time!
✅ CORRECT: TimeSeriesSplit(n_splits=5)
2.5 Hyperparameter Tuning on Test Set
❌ WRONG: grid_search(model, X_test, y_test)
✅ CORRECT: train/validation/test three-way split
Category 3: Training Pitfalls 🔧
3.1 Batch Norm Inference Error
❌ WRONG: predictions = model(X_test) # Still in train mode
✅ CORRECT: model.eval(); with torch.no_grad(): predictions = model(X_test)
3.2 Early Stopping Overfitting
❌ WRONG: EarlyStopping(patience=50)
✅ CORRECT: EarlyStopping(patience=5, min_delta=0.001, restore_best_weights=True)
3.3 Learning Rate Warmup
✅ CORRECT: get_linear_schedule_with_warmup(num_warmup_steps=1000)
3.4 Class Imbalance
❌ WRONG: CrossEntropyLoss() # Biased toward majority
✅ CORRECT: CrossEntropyLoss(weight=class_weights)
Detection Patterns
Leakage Detection
# Check feature-target correlation
correlation = df[features].corrwith(df['target'])
if (correlation.abs() > 0.95).any():
raise DataLeakageError("Suspiciously high correlation")
# Check temporal ordering
if train['date'].min() > test['date'].max():
raise TemporalLeakageError("Training on future, testing on past")
# Check group overlap
if train_groups & test_groups:
raise GroupLeakageError("Overlapping groups")
Mode Check
if model.training:
raise InferenceModeError("Model in training mode during evaluation")
Validation Checklist
Before deployment:
- [ ] No data leakage detected
- [ ] Test set never seen during training
- [ ] Metrics aligned with business objective
- [ ] model.eval() called for inference
- [ ] Class imbalance handled
- [ ] Covariate shift monitoring planned
References
상세 예시 및 시나리오는 references/REFERENCE.md 참조.
同梱ファイル
※ ZIPに含まれるファイル一覧。`SKILL.md` 本体に加え、参考資料・サンプル・スクリプトが入っている場合があります。
- 📄 SKILL.md (4,695 bytes)
- 📎 references/deployment_checklist.md (13,898 bytes)
- 📎 references/evaluation_guidelines.md (12,533 bytes)
- 📎 references/leakage_patterns.md (13,233 bytes)
- 📎 references/REFERENCE.md (6,146 bytes)
- 📎 scripts/detect_leakage.py (11,405 bytes)
- 📎 scripts/validate_split.py (8,359 bytes)