Logo vun Srm Check

Srm Check

Organisatioun
ai-analyst-lab
srm-check

The randomization gate before reading any experiment result. Detect Sample Ratio Mismatch (SRM) in experiment data before any analysis proceeds. Auto-fire when data has columns like "variant", "group", "treatment", "control", "arm", "experiment_group", "bucket", or when the user says "A/B test", "experiment", "treatment vs control", "randomization", "analyze this experiment data".

Iwwersiicht

Editeurai-analyst-lab
Repositoryai-analyst-plugin
Skill-Nummsrm-check
Stären
34
Forks
13
Matgeliwwert Fichieren
1
LizenzMIT
Linken
  • Instruktiounen am Markdown-Format

    Eng SKILL.md-Datei, déi de Modell bei Bedarf luet, soudatt nëmmen Token ufalen, wann eng Ufro tatsächlech dozou passt.

  • Funktionéiert mat all LLM

    KI-Skills si reng Markdown, keen ubidderspezifesche Code. Dofir funktionéiert dëse Skill mat GPT, Claude, Gemini, Grok oder engem lokale Modell.

  • 1 matgeliwwert Dateien

    Skripten, Virlagen a Referenzen, déi de Modell beim Schaffe liese kann. D'Dateie kënnen nëmme gelies ginn a ginn ni ausgeféiert.

  • Open Source

    Vum ai-analyst-lab op GitHub verëffentlecht. Liest de Quelltext, ier Dir de Skill installéiert.

Installatioun

Installéiert de KI-Skill Srm Check an TypingMind, fir e mat all LLM ze benotzen, oder füügt en an en anere KI-Agent an, deen SKILL.md liest.

1

An TypingMind installéieren

TypingMind installéiert e Skill direkt aus sengem GitHub-Dossier — dobäi gëtt SKILL.md gelies, d'Ressourcedateie gi gebëndelt an d'Resultat gëtt lokal gespäichert.

  1. Maacht d'App op a gitt op Plugins → Skills.
  2. Wielt „Vun GitHub installéieren“.
  3. Pecht d'URL vum Skill-Dossier hei drënner an a bestätegt.
    https://github.com/ai-analyst-lab/ai-analyst-plugin/tree/main/ai-analyst-plus/skills/srm-check
  4. Aktivéiert de Skill an all Chat, an deem Dir e benotze wëllt.
Plugins → Skills → Skill afügen → Vu GitHub-URL, pecht dann d'URL vum Dossier an a klickt op Weider.
2

An engem anere KI-Agent installéieren

All KI-Agent, deen d'Format Agent Skills liest, kann dëse Skill benotzen — kopéiert den Dossier an de Skill-Verzeechnes vun deem KI-Agent.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/ai-analyst-lab/ai-analyst-plugin.git /tmp/ai-analyst-plugin
mkdir -p .claude/skills
cp -r /tmp/ai-analyst-plugin/ai-analyst-plus/skills/srm-check .claude/skills/srm-check
Start Claude Code nom Kopéieren nei, fir datt den neie Skill erkannt gëtt.

An TypingMind benotzen

Aktivéiert Srm Check an engem Chat vun TypingMind, an de Modell iwwerhëlt de Rescht. Den Numm an d'Beschreiwung stinn am System-Prompt. Soubal eng Ufro dozou passt, luet de Modell déi komplett Instruktioune selwer — Dir musst de Skill ni manuell opruffen, an et fale keng Token un, bis en tatsächlech benotzt gëtt.

De Modell luet Srm Check automatesch, soubal eng Ufro dozou passt.

Funktionéiert mat all KI-Modell

KI-Skills si reng Markdown-Instruktiounen amplaz vun ubidderspezifeschem Code. Dofir ass Srm Check net un de Modell gebonnen, fir deen de Skill geschriwwe gouf. Installéiert en eemol an TypingMind a benotzt e mat GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder engem lokale Modell, deen Dir selwer bedreift — alles mat Ären eegenen API-Keys.

  • Gëtt nëmme gelueden, wann et néideg ass

    De System-Prompt enthält nëmmen den Numm an d'Beschreiwung. D'Instruktioune gi bei der éischter passender Ufro gelueden, soudatt en onbenotzte Skill näischt kascht.

  • De Modell am lafende Chat wiesselen

    Well de Skill aus Instruktiounen amplaz vu Code besteet, funktionéiert en och no engem Modellwiessel — den nächste Modell liest déi selwecht SKILL.md-Datei.

Skill-Instruktiounen

Dëst ass den Inhalt vu SKILL.md, deen de Modell luet. Liest e virun der Installatioun — e Skill besteet aus Instruktiounen, déi Äre Modell befollegt.

If the skill install path cannot be resolved (some sandboxed environments): read the script file(s) from this skill, write a copy into a scripts/ folder inside the working folder, and run from there. The scripts are self-contained.

Skill: SRM Check (Sample Ratio Mismatch)

Purpose

Automatically detect Sample Ratio Mismatch in experiment data before any analysis proceeds. SRM is a randomization integrity check — if the treatment/control split deviates significantly from the expected ratio, the experiment is compromised and results cannot be trusted. This skill acts as a safety gate that blocks analysis when randomization is broken.

When to Use

Apply this skill when:

  1. Loading any experiment or A/B test dataset — auto-fire on detection of treatment/control columns (e.g., variant, group, treatment, arm, experiment_group)
  2. Before any treatment effect calculation — SRM must pass before comparing outcomes
  3. When the Experiment Analyzer agent starts — first step of any experiment analysis workflow

This skill auto-fires on experiment data detection. Do NOT wait to be asked.

Instructions

What Is SRM?

Sample Ratio Mismatch (SRM) occurs when the observed ratio of users in treatment vs. control deviates significantly from the expected ratio. For a 50/50 experiment with 10,000 users, you expect ~5,000 in each group. If you see 5,500 vs. 4,500, something is wrong with randomization.

SRM CHECK
━━━━━━━━━━
Expected ratio:  50/50 (or whatever was designed)
Observed ratio:  [actual counts]
Test:            Chi-squared goodness-of-fit
Decision:        PASS (proceed) or BLOCK (halt analysis)

Why SRM matters: If randomization is broken, treatment and control groups are NOT comparable. Any observed difference in outcomes could be caused by the broken randomization, not the treatment. SRM is the single most important validity check in experimentation.

Detection Logic

Step 1: Identify the experiment column

Scan the dataset for columns that indicate experiment assignment. Look for:

  • Column names: variant, group, treatment, control, arm, experiment_group, test_group, bucket, condition
  • Column values: binary (0/1, control/treatment, A/B), or small number of distinct values (< 10)
  • User language: phrases like "A/B test", "experiment", "treatment vs control", "randomization"
  • Metadata: check for experiment config files in .knowledge/experiments/

If NO experiment indicators are found: This skill does not apply. Do not generate any SRM-related output. Do not explain why the check doesn't apply, do not document the detection logic, do not mention SRM at all. Simply proceed with the user's request as if the SRM Check skill was never loaded. The user is asking for segmentation or comparison analysis, not experiment validation — give them what they asked for without SRM commentary.

Step 2: Determine expected ratio
  • If metadata is available (experiment config, brief, or user-specified): use the designed ratio
  • If no metadata: default to equal allocation (50/50 for 2 groups, 33/33/33 for 3 groups, etc.)
  • Ask the user if uncertain: "This looks like an experiment with [N] groups. Was the intended split equal, or was there a specific allocation ratio?"
Step 3: Run the SRM test

Use a chi-squared goodness-of-fit test. The deterministic implementation is bundled in this skill at scripts/srm.py (needs pandas, numpy, scipy). Add this skill's scripts/ directory to sys.path and import from it:

python
import sys
sys.path.insert(0, "<path to this skill>/scripts")  # the scripts/ dir next to this SKILL.md
from srm import srm_check

# observed counts per group
result = srm_check(
    observed_counts=[n_control, n_treatment],
    expected_ratios=[0.5, 0.5],  # or designed ratio
)
# Returns: chi2_stat, p_value, verdict (PASS/WARNING/BLOCK), interpretation

chi2 = result["chi2_stat"]
p_value = result["p_value"]
verdict = result["verdict"]

For segmented SRM diagnosis (find WHICH segments have broken randomization):

python
from srm import srm_diagnose  # same bundled scripts/srm.py module

diag = srm_diagnose(assignments_df, segments=["platform", "country"])
# Returns per-segment SRM results to identify the source of the mismatch
Step 4: Interpret and decide
p-valueVerdictAction
p > 0.05PASSRandomization looks clean. Proceed with analysis.
0.01 < p ≤ 0.05WARNINGMarginal SRM. Proceed with caution. Flag in report.
p ≤ 0.01BLOCKSRM detected. HALT analysis. Investigate before proceeding.
Step 5: Temporal stability check (if applicable)

If the experiment ran for multiple days/weeks, check SRM over time:

  1. Group data by time period (day, week, or other natural breakpoint based on experiment duration)
  2. Run SRM check for each period using the same chi-squared test
  3. Flag any period where p ≤ 0.05 (indicates intermittent SRM)

Why this matters: SRM can start mid-experiment due to bugs, infrastructure changes, or experiment modifications. A clean aggregate SRM might mask periods where randomization was broken.

Output format:

markdown
### SRM Over Time

| Period | Expected | Observed | Chi-squared | p-value | Verdict |
|--------|----------|----------|-------------|---------|---------|
| Week 1 | 50/50 | 5,012/4,988 | 0.058 | 0.81 | PASS |
| Week 2 | 50/50 | 5,300/4,700 | 36.0 | <0.001 | BLOCK |

If any period shows WARNING or BLOCK, investigate before trusting the aggregate result.

When SRM is Detected (BLOCK)

If the SRM check returns BLOCK:

  1. HALT all downstream analysis — do NOT compute treatment effects, segment analyses, or recommendations. Results from a broken experiment are unreliable.

  2. Report the finding clearly:

markdown
## SRM CHECK: BLOCKED

| Group | Expected | Observed | Deviation |
|-------|----------|----------|-----------|
| Control | [N] ([X]%) | [N] ([X]%) | [+/- Y%] |
| Treatment | [N] ([X]%) | [N] ([X]%) | [+/- Y%] |

**Chi-squared test:** χ² = [value], p = [value]
**Verdict:** Sample Ratio Mismatch detected. Analysis halted.
  1. Suggest investigation paths:

    • Was there a bug in the assignment logic? (Check if certain user types were excluded from one group)
    • Did the feature fail to load for some users? (Treatment users who never saw the treatment get dropped)
    • Was there a data pipeline issue? (Events from one group not logged properly)
    • Was the experiment stopped and restarted? (Can cause ratio imbalances)
  2. Offer options:

    • "Investigate the cause of the SRM before analyzing results"
    • "Proceed with analysis anyway (NOT RECOMMENDED — results may be invalid)"
    • "Filter to a time window where the ratio was clean (if SRM started at a specific point)"

Output Format

Always include the SRM check result at the top of any experiment analysis:

markdown
## Validity Check: Sample Ratio

| Metric | Value |
|--------|-------|
| Expected ratio | [X/Y] |
| Observed | Control: [N] ([X]%), Treatment: [N] ([Y]%) |
| Chi-squared | χ² = [value] |
| p-value | [value] |
| **Verdict** | **PASS / WARNING / BLOCK** |

If PASS: continue analysis. If WARNING: add a note to all findings: "Note: Marginal SRM detected (p = X.XX). Results should be interpreted with caution." If BLOCK: halt and report as described above.

Anti-Patterns

  1. Never skip the SRM check — even if the split "looks close enough," run the statistical test. A 51/49 split on 100K users is a significant SRM.
  2. Never proceed with analysis after a BLOCK unless the user explicitly overrides — invalid randomization means invalid results
  3. Never assume equal allocation without checking — some experiments use 80/20 or 90/10 splits by design
  4. Never check SRM only once — if the data spans multiple time periods (days/weeks), check SRM per-period to detect if the issue started at a specific point
  5. Never dismiss SRM as "close enough" — SRM is binary. Either randomization worked or it didn't. There is no "close enough" for randomization integrity.
  6. Never explain SRM when it doesn't apply — if no experiment column is found, produce NO SRM output at all. Exit truly silently without documentation or explanation.

Matgeliwwert Fichieren

De Modell liest dës Dateie bei Bedarf, wärend de Skill gelueden ass. Si ginn als liesbar Dateie bereetgestallt a ginn ni ausgeféiert.

Heefeg gestallte Froen

Wat mécht de KI-Skill Srm Check?

The randomization gate before reading any experiment result. Detect Sample Ratio Mismatch (SRM) in experiment data before any analysis proceeds. Auto-fire when data has columns like "variant", "group", "treatment", "control", "arm", "experiment_group", "bucket", or when the user says "A/B test", "experiment", "treatment vs control", "randomization", "analyze this experiment data".

Firwat Srm Check op TypingMind benotzen?

Well Dir en eemol installéiert a mat all Modell benotze kënnt. Srm Check besteet aus einfachem Markdown amplaz vun ubidderspezifeschem Code. Dee selwechte Skill funktionéiert also mat GPT-5, Claude, Gemini, Grok oder engem lokale Modell – an Dir kënnt de Modell matzen am Chat wiesselen, ouni datt de Skill ophält ze funktionéieren. TypingMind benotzt Är eegen API-Schlësselen, sou datt Dir d'Ubidder direkt bezuelt amplaz vun engem Abonnement pro Benotzerplaz. Är Skills a Chats bleiwen an Ärem eegene Späicher.

Wéi installéieren ech Srm Check an TypingMind?

Maacht an TypingMind Plugins → Skills → Vu GitHub installéieren op a setzt https://github.com/ai-analyst-lab/ai-analyst-plugin/tree/main/ai-analyst-plus/skills/srm-check an. TypingMind liest d'Datei SKILL.md, bündelt déi zougehéiereg Dateien an installéiert dat Ganzt als Skill, deen Dir pro Chat aktivéiere kënnt.

Wéi eng KI-Modeller kënnen Srm Check benotzen?

All Modell, deen Dir an TypingMind verbënnt. KI-Skills sinn einfach Markdown-Instruktiounen an net ubidderspezifesche Code. Dofir kënne GPT, Claude, Gemini, Grok a lokal Modeller dëse Skill lueden, wann eng Ufro dozou passt.

Wéi vill KI-Modeller kann ech mat Srm Check benotzen?

Esou vill Dir wëllt. Soulaang e Modell Skills ënnerstëtzt, kënnt Dir Srm Check domat benotzen – GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama a méi – alles op TypingMind mat Ären eegenen API-Schlësselen.

Ass de KI-Skill Srm Check gratis?

Jo. De Skill gëtt vum ai-analyst-lab ënner der Lizenz MIT op GitHub publizéiert. Dir bezuelt nëmmen Ären eegene KI-Ubidder fir d'Token, déi Dir benotzt.

Wat si KI-Skills?

E KI-Skill ass e weiderverwendbaart Pak vun Instruktiounen, dat engem KI-Modell bäibréngt, wéi en eng bestëmmt Aufgab erfëllt. E follegt dem oppenen Agent Skills-Format: eng Datei SKILL.md mat engem Numm an enger Beschreiwung, plus all Scripten, Virlagen oder Referenzdateien, déi de Modell eventuell brauch. De Modell liest d'Instruktiounen eréischt, wann Är Ufro zum Skill passt. En installéierte Skill kascht also näischt, bis e benotzt gëtt.

Wéi ënnerscheede sech KI-Skills vu Plugins oder MCP-Serveren?

E Plugin oder MCP-Server gëtt engem Modell nei Tools, déi en opruffe kann – Code, deen iergendwou leeft an e Resultat zeréckgëtt. E KI-Skill gëtt dem Modell dogéint Wëssen an eng Virgoensweis: wéi en eng Aufgab ugeet, wéi eng Schrëtt en nokënnt a wéi eng gutt Ausgab ausgesäit. Skills bestinn aus einfachem Markdown, brauche kee Server, keen API-Schlëssel a keng Lafzäitëmfeld a funktionéiere mat all Modell.

All weisen

Elo Ären eegene KI-Workspace ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇