Back to Skills

run-ab-test-models

pjt222
Updated 6 days ago
16 views
17
2
17
View on GitHub
Testingaitestingdesigndata

About

This skill enables A/B testing for ML models in production using traffic splitting and statistical significance testing. It supports canary and shadow deployments to measure performance differences for data-driven rollout decisions. Use it to validate new model versions, compare algorithms, or meet gradual rollout requirements.

Quick Install

Claude Code

Recommended
Primary
npx skills add pjt222/agent-almanac -a claude-code
Plugin CommandAlternative
/plugin add https://github.com/pjt222/agent-almanac
Git CloneAlternative
git clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/run-ab-test-models

Copy and paste this command in Claude Code to install this skill

Documentation

行 A/B 模測

全配與板見 Extended Examples

於產分流、計析、金/影釋以較模本。

  • 釋新模本欲驗於全→用
  • 較異算/特之候模→用
  • 試超參改於業指影→用
  • 量產上模效不冒全流→用
  • 監管漸釋(如醫 ML)→用
  • 評費效衡(模大)→用

  • :冠模(當產本)
  • :挑模(試新本)
  • :流分比(如 5% 予挑)
  • :成指(業與 ML)
  • :最小樣或測時
  • :護指(延、誤率限)
  • :用段(分層測)

一:設驗

定測參、成準、計需。

# ab_test/experiment_config.py
from dataclasses import dataclass
from typing import List, Dict
import numpy as np
from scipy.stats import norm


@dataclass
# ... (see EXAMPLES.md for complete implementation)

得:驗配含計健全之樣大算,常 5-10k/變於 5-10% MDE。

敗:樣需過大→增分、延時、納大 MDE;驗基指準;考序測續察。

二:行流分

設路邏隨配請於模。

# ab_test/traffic_router.py
import hashlib
import random
from typing import Dict, Optional
from dataclasses import dataclass
import logging

logger = logging.getLogger(__name__)
# ... (see EXAMPLES.md for complete implementation)

得:用-變一致配、流分準合配比、諸配記以析。

敗:驗散函生均勻(試 10k user_id)、查 user_id 跨請求穩(非 session_id)、確日誌捕諸測事件、首 1000 請驗分。

三:行影釋(可)

並行挑模而不擾用(影模)。

# ab_test/shadow_deployment.py
import asyncio
from typing import Dict, Any
import logging
from concurrent.futures import ThreadPoolExecutor
import time

logger = logging.getLogger(__name__)
# ... (see EXAMPLES.md for complete implementation)

得:冠測常延供、挑測異步記不阻、測異捕以析。

敗:挑超時 < 冠 SLA、優雅理挑誤、察記憶(兩模載)、考採樣(記 10% 影測)。

四:採析指

集驗資、行計測。

# ab_test/analysis.py
import pandas as pd
import numpy as np
from scipy import stats
from typing import Dict, Tuple
import logging

logger = logging.getLogger(__name__)
# ... (see EXAMPLES.md for complete implementation)

得:計測果含 p、信區、明決(釋/留/未定),常 7-14 日後或達樣。

敗:驗真標可(或需延析)、查樣比錯(SRM)示配漏、足樣達、察初新/首因、考序測若定平太緩。

五:察護指

續查挑不破安限。

# ab_test/guardrails.py
import pandas as pd
import logging
from typing import Dict, List

logger = logging.getLogger(__name__)


# ... (see EXAMPLES.md for complete implementation)

得:護違 5-15 分內察、自停若關限破(延、誤)、警送組。

敗:驗護限現實(不過嚴)、確察循環續行、查 stop_experiment() 真更路、測警送。

六:作釋決

按驗果決挑釋否。

# ab_test/rollout_decision.py
import logging
from typing import Dict
from dataclasses import dataclass

logger = logging.getLogger(__name__)


# ... (see EXAMPLES.md for complete implementation)

得:明決(全/漸釋、留冠、延測)含理與行項。

敗:決不明→行子組析(按段、時、機)、查互效、覆業境(2% 升值工本乎?)、徵相關方。

  • 流分合配比(內 1%)
  • 同用恆配同變(一致查)
  • 樣大算合理(5-50k/變)
  • 計測 p 合手算
  • 護違 5 分內警
  • 影釋示模測異 < 5%
  • 驗報含信區
  • 釋決文錄附理

  • 樣比錯(SRM):察分異於配(95/5 變 92/8)→配漏;查散函均
  • :未達樣前查果脹一型誤;用序測或待定終
  • 新效:用初應殊;行 ≥ 2 週見穩態
  • 承效:前變露擾今;用新用或足洗期
  • 多測:多指增假陽;以 Bonferroni 正或重一主指
  • 力不足:小流配需月察實效;平衡計力與險忍
  • 忽段:聚升可藏要段負影;行子組析
  • 歸誤:確指正歸於模測(非他系變)

  • deploy-ml-model-serving
  • monitor-model-drift

GitHub Repository

pjt222/agent-almanac
Path: i18n/wenyan-ultra/skills/run-ab-test-models
0
agentsagentskillsai-assisted-developmentclaude-codeskillsteams

Related Skills

evaluating-llms-harness

Testing

This Claude Skill runs the lm-evaluation-harness to benchmark LLMs across 60+ standardized academic tasks like MMLU and GSM8K. It's designed for developers to compare model quality, track training progress, or report academic results. The tool supports various backends including HuggingFace and vLLM models.

View skill

cloudflare-cron-triggers

Testing

This skill provides comprehensive knowledge for implementing Cloudflare Cron Triggers to schedule Workers using cron expressions. It covers setting up periodic tasks, maintenance jobs, and automated workflows while handling common issues like invalid cron expressions and timezone problems. Developers can use it for configuring scheduled handlers, testing cron triggers, and integrating with Workflows and Green Compute.

View skill

webapp-testing

Testing

This Claude Skill provides a Playwright-based toolkit for testing local web applications through Python scripts. It enables frontend verification, UI debugging, screenshot capture, and log viewing while managing server lifecycles. Use it for browser automation tasks but run scripts directly rather than reading their source code to avoid context pollution.

View skill

finishing-a-development-branch

Testing

This skill helps developers complete finished work by verifying tests pass and then presenting structured integration options. It guides the workflow for merging, creating PRs, or cleaning up branches after implementation is done. Use it when your code is ready and tested to systematically finalize the development process.

View skill