跳到正文
cccskills
免费在 GitHub 公开

run-ab-test-models

Design and execute A/B tests for ML models in production using traffic splitting, statistical significance testing, and canary/shadow deployment strategies. Measure performance differences and make data-driven decisions about model rollout. Use when validating a new model version before full rollout, comparing candidate models trained with different algorithms, measuring business metric impact of model changes, or when regulatory requirements mandate gradual rollout.

中文简介正在准备中。当前显示原文说明。

查看安装方法

包含的文件(2)

  • SKILL.md7.9 KB
  • references/EXAMPLES.md27.2 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

Run A/B Test for Models

See Extended Examples for complete configuration files and templates.

Execute controlled experiments comparing model versions using traffic splitting and statistical analysis.

When to Use

  • Deploying new model version and want to validate improvement before full rollout
  • Comparing multiple candidate models trained with different algorithms or features
  • Testing impact of hyperparameter changes on business metrics
  • Need to measure model performance in production without risking full traffic
  • Regulatory requirements for gradual rollout (e.g., medical ML systems)
  • Evaluating cost-performance tradeoffs between model sizes

Inputs

  • Required: Champion model (current production version)
  • Required: Challenger model(s) (new version to test)
  • Required: Traffic allocation percentage (e.g., 5% to challenger)
  • Required: Success metrics (business and ML metrics)
  • Required: Minimum sample size or test duration
  • Optional: Guardrail metrics (latency, error rate thresholds)
  • Optional: User segments for stratified testing

Procedure

Step 1: Design Experiment

Define test parameters, success criteria, and statistical requirements.

# 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)

Expected: Experiment configuration with statistically sound sample size calculation, typically 5-10k samples per variant for 5-10% MDE.

On failure: If required sample size too large, increase traffic allocation, extend test duration, or accept larger MDE; verify baseline metric estimate is accurate; consider sequential testing for continuous monitoring.

Step 2: Implement Traffic Splitting

Set up routing logic to randomly assign requests to models.

# 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)

Expected: Consistent user-to-variant assignment, accurate traffic split matching configured percentages, all assignments logged for analysis.

On failure: Verify hash function produces uniform distribution (test with 10k user IDs), check that user_id is stable across requests (not session_id), ensure logs capture all prediction events, validate traffic split in first 1000 requests.

Step 3: Implement Shadow Deployment (Optional)

Run challenger model in parallel without affecting users (shadow mode).

# 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)

Expected: Champion predictions served with normal latency, challenger predictions logged asynchronously without blocking, prediction differences captured for analysis.

On failure: Set challenger timeout < champion SLA to avoid blocking, handle challenger errors gracefully without affecting champion, monitor memory usage (two models loaded), consider sampling (log only 10% of shadow predictions).

Step 4: Collect and Analyze Metrics

Gather experiment data and perform statistical tests.

# 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)

Expected: Statistical test results with p-values, confidence intervals, and clear decision (rollout/keep/inconclusive), typically after 7-14 days or reaching sample size.

On failure: Verify ground truth labels are available (may need delayed analysis), check for sample ratio mismatch (SRM) indicating assignment bugs, ensure sufficient sample size reached, look for novelty/primacy effects in early data, consider sequential testing if fixed-horizon test is too slow.

Step 5: Monitor Guardrail Metrics

Continuously check that challenger doesn't violate safety thresholds.

# 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)

Expected: Guardrail violations detected within 5-15 minutes, automated experiment stop if critical thresholds breached (latency, errors), alerts sent to team.

On failure: Verify guardrail thresholds are realistic (not too tight), ensure monitoring loop is running continuously, check that stop_experiment() function actually updates routing, test alert delivery channels.

Step 6: Make Rollout Decision

Based on experiment results, decide whether to rollout challenger.

# 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)

Expected: Clear decision (full/gradual rollout, keep champion, or extend test) with justification and action items.

On failure: If decision unclear, perform subgroup analysis (by user segment, time of day, device type), check for interaction effects, review business context (e.g., is 2% lift worth engineering cost?), consult with stakeholders.

Validation

  • Traffic split matches configured percentages (within 1%)
  • Same user always assigned to same variant (consistency check)
  • Sample size calculation produces reasonable numbers (5-50k per variant)
  • Statistical tests produce p-values consistent with manual calculation
  • Guardrail violations trigger alerts within 5 minutes
  • Shadow deployment shows <5% prediction divergence between models
  • Experiment reports include confidence intervals
  • Rollout decision documented with justification

Common Pitfalls

  • Sample ratio mismatch (SRM): If observed traffic split differs from configured (e.g., 95/5 becomes 92/8), indicates assignment bug; check hash function uniformity
  • Peeking: Checking results before reaching sample size inflates Type I error; use sequential testing or wait for pre-determined end date
  • Novelty effect: Users respond differently to new model initially; run for 2+ weeks to see steady-state behavior
  • Carryover effects: Previous variant exposure affects current behavior; use new users or sufficient washout period
  • Multiple testing: Testing many metrics increases false positive risk; correct with Bonferroni or focus on single primary metric
  • Insufficient power: Small traffic allocation may require months to detect realistic effects; balance statistical power with risk tolerance
  • Ignoring segments: Aggregate lift may hide negative impact on important user segments; perform subgroup analysis
  • Attribution errors: Ensure outcome metrics correctly attributed to model predictions (not other system changes)

Related Skills

  • deploy-ml-model-serving - Model deployment infrastructure and versioning
  • monitor-model-drift - Ongoing performance monitoring post-rollout

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Execute structural metamorphosis using strangler fig migration, chrysalis phases, and interface preservation. Covers transformation planning, parallel running, progressive cutover, rollback design, and post-metamorphosis stabilization for system architecture evolution. Use when assess-form has classified the system as READY for transformation, when migrating from monolith to microservices, when replacing a core subsystem while dependents continue operating, or when any architectural change must be gradual rather than big-bang.

中文简介正在准备中。当前显示原文说明。

pjt222/agent-almanac422026年10月21日 更新

adaptic

免费

Master skill composing the 5-step synoptic cycle for panoramic synthesis across multiple domains. Orchestrates meditate, expand-awareness, observe, awareness, integrate-gestalt, and express-insight into a coherent process that produces unified understanding rather than sequential compromise. Use when a problem genuinely spans 3+ domains and the interactions between domains matter more than depth in any one, when sequential analysis feels like compromise rather than integration, or before major architectural decisions affecting multiple stakeholders.

中文简介正在准备中。当前显示原文说明。

pjt222/agent-almanac422026年10月21日 更新

Scaffold a new puzzle type across all 10+ pipeline integration points in jigsawR. Creates the core puzzle module, wires it into the unified pipeline (generation, positioning, rendering, adjacency), adds ggpuzzle geom/stat layers, updates DESCRIPTION and config.yml, extends the Shiny app, and creates a comprehensive test suite. Use when adding a completely new puzzle type to the package or following the 10-point integration checklist to ensure nothing is missed end-to-end.

中文简介正在准备中。当前显示原文说明。

pjt222/agent-almanac422026年10月21日 更新

Add Rcpp or RcppArmadillo integration to an R package for high-performance C++ code. Covers setup, writing C++ functions, RcppExports generation, testing compiled code, and debugging. Use when an R function is too slow and profiling confirms a bottleneck, when you need to interface with existing C/C++ libraries, or when implementing algorithms (loops, recursion, linear algebra) that benefit from compiled code.

中文简介正在准备中。当前显示原文说明。

pjt222/agent-almanac422026年10月21日 更新

aikido

免费

Practice aikido as a defensive martial art emphasizing harmony, redirection, and controlled resolution. Covers centering and grounding, ukemi (safe falling and rolling), core techniques (irimi-nage, shiho-nage, kote-gaeshi, ikkyo), blending and tai sabaki (body movement), randori (multiple attacker practice), weapons awareness, and applying principles off the mat. Use when learning a defensive martial art that prioritizes de-escalation, developing the ability to redirect aggression without causing unnecessary harm, building safe falling skills, or cultivating calm centeredness under physical pressure.

中文简介正在准备中。当前显示原文说明。

pjt222/agent-almanac422026年10月21日 更新

Analyze an arbitrary codebase to identify functions, APIs, and data sources suitable for exposure as MCP tools, producing a tool specification document. Use when planning an MCP server for an existing project, auditing a codebase before wrapping it as an AI-accessible tool surface, comparing what a codebase can do versus what is already exposed via MCP, or generating a tool spec to hand off to scaffold-mcp-server.

中文简介正在准备中。当前显示原文说明。

pjt222/agent-almanac422026年10月21日 更新

查看 pjt222 的全部技能

报告此技能的问题