first commit

This commit is contained in:
2026-06-11 03:33:14 +08:00
commit 5f555bf342
599 changed files with 142347 additions and 0 deletions

View File

@@ -0,0 +1,252 @@
---
name: results-analysis
description: This skill should be used when the user asks to "analyze experimental results", "run strict statistical analysis", "compare model performance", "generate scientific figures", "check significance", "do ablation analysis", or mentions interpreting experiment data with rigorous statistics and visualization. It focuses on strict analysis bundles, not Results-section prose.
tags: [Research, Analysis, Statistics, Visualization, Scientific Reporting]
version: 0.2.0
---
# Results Analysis
Run **strict, evidence-first experimental analysis** for ML/AI research.
Use this skill to produce a **strict analysis bundle**:
- `analysis-report.md`
- `stats-appendix.md`
- `figure-catalog.md`
- `figures/`
When the user asks for review, audit, no-write, dry-run, or when inputs are incomplete, use **read-only audit mode** instead of producing files or figures. In that mode, output only valid/invalid statistics, blockers, claim candidates, and what evidence is missing. If invoked by `/analyze-results`, the command layer may write a blocker summary, but this skill should not create figures, reports, or polished conclusions from incomplete evidence.
Do **not** use this skill to draft a paper `Results` section or a full experiment wrap-up report. Those belong to `ml-paper-writing` or `results-report`.
## Core contract
### This skill is responsible for
- validating experiment artifacts and comparison units,
- running rigorous descriptive and inferential statistics,
- generating **real scientific figures** when data/logs are available,
- writing figure purposes, caption requirements, and interpretation checklists,
- surfacing limits, blockers, and missing evidence explicitly.
### This skill is not responsible for
- paper-ready `Results` prose,
- manuscript narrative polishing,
- paper-ready figure/table packaging with `pubfig` / `pubtab`,
- project-level experiment retrospectives.
If the user wants the complete post-experiment summary report, hand off to `results-report` after this bundle is ready. If the user wants publication-grade figures/tables, export parameters, publication QA, or figure/table redesign, hand off to `publication-chart-skill`.
## Non-negotiable quality bar
1. **Prefer real figures over figure specs.**
If the data can be read, generate real figures. Do not stop at “recommended visualization”.
Exception: in read-only audit mode, do not generate figures; describe what figure would be valid after evidence is complete.
2. **Never fabricate statistics.**
If sample size, seeds, or raw metrics are missing, state the blocker clearly.
3. **Report complete statistics.**
Do not report only best scores or only p-values.
4. **Interpret every main figure.**
Every major figure must have purpose, caption requirements, and post-figure interpretation notes.
5. **Separate evidence from prose.**
This skill produces analysis artifacts; it does not write manuscript sections.
## Standard workflow
### 1. Inventory and validate artifacts
Start by identifying:
- metric tables (`csv`, `json`, `tsv`, logs),
- training curves and checkpoints,
- seeds / repeated runs,
- baselines, ablations, and comparison families,
- evaluation protocol metadata.
Validate:
- metric direction (higher/lower is better),
- unit of analysis (run, subject, fold, dataset, seed),
- number of runs / seeds,
- missing values or silent failures,
- comparability across methods.
If the comparison is not statistically valid, say so before continuing. Do not treat repeated `subject × task` rows, folds, windows, trials, or seeds as independent units unless the design justifies it.
Common blocker: a `subject × task` summary table is usually a repeated-measure summary, not an independent subject-level sample. If subjects have multiple task rows or missing task cells, state that before any significance or winner claim.
### 2. Lock the comparison questions
Before running statistics, define the exact comparison questions:
- Which method is compared to which baseline?
- What is the primary metric?
- What is the repeated-measure unit?
- Which ablation or robustness questions matter?
- Which findings are decision-changing?
Do not mix unrelated comparisons into one undifferentiated table.
### 3. Run strict statistics
Always produce:
- descriptive statistics: `mean ± std` when appropriate,
- `95% CI` or another clearly justified interval,
- run/seed counts,
- significance tests with assumptions stated,
- effect sizes,
- multiple-comparison handling when several contrasts are reported.
Default expectation:
- check parametric assumptions first,
- use non-parametric fallback when assumptions fail,
- state exactly what was tested and on what samples.
See:
- `references/statistical-methods.md`
- `references/statistical-reporting.md`
### 4. Generate real scientific figures
Produce actual figures whenever artifacts are available.
Minimum expectation for a non-trivial analysis bundle:
- **one main comparison figure**,
- **one supporting figure** (training dynamics / ablation / breakdown / error analysis),
- **one exact numeric summary table** in markdown.
Every main figure must define:
- figure purpose,
- plotted variables,
- error bar meaning,
- caption requirements,
- interpretation checklist.
See:
- `references/visualization-best-practices.md`
- `references/figure-interpretation.md`
### 5. Write analysis artifacts
#### `analysis-report.md`
Summarize:
- the analysis question,
- key findings,
- strongest supported comparisons,
- main caveats,
- what changed in the experimental understanding,
- claim candidates that may later be used in reports or manuscript writing.
Each claim candidate should use this shape:
```md
## Claim Candidates
- Claim:
- Source evidence:
- Allowed wording:
- Forbidden stronger wording:
- Uncertainty:
- Next check:
- Decision: keep | weaken | revise | discard
```
#### `stats-appendix.md`
Record:
- descriptive statistics,
- test choices,
- assumptions checked,
- effect sizes,
- confidence intervals,
- multiple comparison corrections,
- explicit blockers and limitations.
#### `figure-catalog.md`
For each figure, record:
- filename,
- purpose,
- data source,
- caption draft requirements,
- key observation,
- interpretation checklist,
- known caveats.
### 6. Final QA gate
Do not finish until all are true:
- [ ] the primary comparison question is explicit,
- [ ] sample size / seed count is stated,
- [ ] inferential tests are justified,
- [ ] effect sizes are reported for major contrasts,
- [ ] real figures exist when data exists,
- [ ] each figure has an interpretation note,
- [ ] limitations and blockers are explicit,
- [ ] each supported or strong claim candidate has evidence, uncertainty, and allowed wording,
- [ ] over-strong manuscript wording is explicitly blocked when evidence is insufficient,
- [ ] no manuscript-style `Results` draft is included.
## Output structure
```text
analysis-output/
├── analysis-report.md
├── stats-appendix.md
├── figure-catalog.md
└── figures/
├── figure-01-main-comparison.pdf
├── figure-02-ablation.pdf
└── ...
```
## Figure interpretation rule
For every major figure, answer all three questions:
1. **Why does this figure exist?**
2. **What exactly should the reader notice?**
3. **What does that observation change in our belief or next decision?**
If a figure cannot answer question 3, it is probably decorative rather than scientific.
## Read-only audit mode
Use this mode when:
- the user asks to audit or review existing artifacts,
- the environment is read-only,
- the user forbids file writes or figure generation,
- core evidence is missing.
Return:
- analysis questions,
- valid statistics,
- invalid or unsafe statistics,
- claim candidates with allowed and forbidden wording,
- blockers before report/figure generation.
Do not create `analysis-output/`, figures, or reports in this mode.
Quarantine any statistics file whose interpretation contradicts its own p-value, test method, unit of analysis, or comparison family. Do not reuse that file for claim wording until provenance is checked.
## Failure mode policy
When inputs are incomplete, say so explicitly.
Examples:
- no seed-level data -> descriptive summary only; inferential claims blocked,
- no comparable baseline outputs -> no significance claim,
- no readable logs -> cannot generate dynamics figure,
- too few runs -> effect size may be unstable; report this limitation.
- unclear unit of analysis -> no winner claim or significance claim,
- analysis file with contradictory interpretation -> quarantine it until provenance is checked.
Never replace missing evidence with confident prose.
## Reference files
Load only what is needed:
- `references/statistical-methods.md` - test selection and assumptions
- `references/statistical-reporting.md` - minimum reporting standard
- `references/visualization-best-practices.md` - publication-quality figure rules
- `references/figure-interpretation.md` - how to explain figures with evidence
- `references/analysis-depth.md` - move from observation to mechanism and decision
- `references/common-pitfalls.md` - common analysis and reporting failures
- `../research-ideation/references/research-contract.md` - shared claim candidate and claim strength contract
## Example files
- `examples/example-analysis-report.md`
- `examples/example-stats-appendix.md`
- `examples/example-figure-catalog.md`

View File

@@ -0,0 +1,131 @@
# Results Analysis Usage
本技能用于生成 **strict analysis bundle**,不是写论文 Results 草稿。
## 默认产物
```text
analysis-output/
├── analysis-report.md
├── stats-appendix.md
├── figure-catalog.md
└── figures/
```
## 典型调用路径
```text
/analyze-results (Command)
results-analysis (Skill)
results-report (Skill, optional follow-up)
```
## 适用场景
- 多模型对比,需要严谨统计
- 多 seed / 多 subject / 多 fold 结果汇总
- 需要真实科研图,而不是只给 figure specs
- 需要为后续 `results-report` 提供可信分析底座
## 推荐工作流
### 1. 准备输入
至少整理出以下之一:
- seed-level `csv/json`
- 每个实验的日志或目录
- baseline 与 ablation 的对应结果
- 训练曲线 / evaluation 曲线 / confusion 或 breakdown 数据
### 2. 运行 `/analyze-results`
```bash
/analyze-results path/to/results full
```
### 3. 期望输出
#### `analysis-report.md`
- 本轮分析回答的问题
- 关键发现
- 哪些比较成立 / 不成立
- 主要 caveats
- 哪些发现值得进一步写成完整实验报告
#### `stats-appendix.md`
- `mean ± std`
- `95% CI`
- significance tests
- effect sizes
- multiple-comparison correction
- assumptions / fallback tests
- blockers
#### `figure-catalog.md`
- 每张图的文件名
- 图用途
- 数据来源
- caption 必须包含的信息
- 图后 interpretation checklist
#### `figures/`
- 真实科研图,优先 PDF/PNG 等可复用格式
## 最低质量要求
### 统计
- 不能只报 best score
- 不能只报 p-value
- 不能混淆 std 和 sem
- 有多组比较时要说明 correction
- 假设不满足时必须切换或说明 non-parametric test
### 图表
- 有数据就要画真实图
- 每个主图都要有误差条或不确定性信息(如适用)
- 图必须有明确用途,不能只是“好看”
- 图后必须说明看到了什么、意味着什么
### 解释
- 先写 observation再写 interpretation最后写 implication
- 若无法支持 causal/mechanistic claim必须保守表述
## 与 `results-report` 的关系
- `results-analysis`:负责严格统计、图表、证据核查
- `results-report`:负责完整实验总结报告、叙事、复盘与决策
推荐顺序:
```text
experiment artifacts
results-analysis
strict analysis bundle
results-report
```
## 边界情况
### 输入不完整
若缺少 seed-level 数据、日志或可比 baseline
- 明确列出缺失项
- 降级分析强度
- 不生成超出证据边界的结论
### 无法出图
如果数据结构不支持直接画图:
- 先说明原因
- 指出还需要哪些字段
- 不要拿“visualization specs”替代真实图作为完成态
## 参考阅读
- `references/statistical-reporting.md`
- `references/figure-interpretation.md`
- `references/analysis-depth.md`
- `references/common-pitfalls.md`

View File

@@ -0,0 +1,57 @@
# Strict Analysis Report
## Analysis Question
- Compare Full Model, Frozen Encoder, and Subject Adapter on cross-subject decoding.
- Determine whether the adapter closes the transfer gap without sacrificing stability.
## Data Inventory
- 3 model families
- 5 random seeds per family
- subject-level WER and CER
- training logs for convergence
- ablation outputs for adapter width
## Executive Summary
- Subject Adapter improves mean WER over Frozen Encoder by 3.8 absolute points.
- The improvement is statistically significant under paired testing after multiple-comparison correction.
- Full fine-tuning remains strongest overall, but Subject Adapter offers the best compute-performance tradeoff.
- Performance variance is lower than Frozen Encoder, suggesting a more stable transfer path.
## Main Findings
### 1. Main comparison
- Full fine-tuning: `31.4 ± 1.9` WER
- Subject Adapter: `33.2 ± 1.3` WER
- Frozen Encoder: `37.0 ± 2.1` WER
Observation:
- Subject Adapter consistently outperforms Frozen Encoder across all 5 seeds.
Interpretation:
- The transfer bottleneck is not purely feature reuse; a light adaptation head captures subject-specific alignment that freezing alone misses.
Implication:
- Future work should prioritize adapter variants before investing in heavier full-model tuning.
### 2. Stability
- Subject Adapter has the smallest seed variance among transfer-friendly methods.
- Convergence curves show less oscillation after epoch 8.
Interpretation:
- Adapter tuning is not only better on average, but easier to optimize.
### 3. Ablation
- Reducing adapter width from 256 to 64 hurts WER by 1.6 points.
- Increasing from 256 to 512 yields only marginal improvement.
Interpretation:
- Most of the benefit is captured at moderate width; scale-up is not the current bottleneck.
## Caveats
- Only 5 seeds; inference about tails remains limited.
- Subject count is modest, so subject-level heterogeneity may still be under-estimated.
- Training-time comparison depends on identical hardware assumptions.
## Recommended Next Move
- Promote this finding into a `results-report` note focused on adapter vs freezing.
- Run one robustness pass on held-out low-resource subjects.

View File

@@ -0,0 +1,33 @@
# Figure Catalog
## Figure 1 — Main comparison
- **Filename**: `figures/figure-01-main-comparison.pdf`
- **Purpose**: Compare WER across Full fine-tuning, Subject Adapter, and Frozen Encoder.
- **Data source**: `metrics/summary.csv`
- **Plot type**: Bar + scatter overlay of seed-level points.
- **Error bars**: 95% CI.
- **Caption must include**:
- metric direction,
- number of seeds,
- meaning of error bars,
- whether significance markers are corrected.
- **Key observation**: Subject Adapter closes most of the freezing gap.
- **Interpretation checklist**:
- Is the adapter improvement consistent across seeds?
- Is the gap practically meaningful, not just statistically significant?
- Does the figure support a design decision?
## Figure 2 — Convergence dynamics
- **Filename**: `figures/figure-02-training-dynamics.pdf`
- **Purpose**: Compare optimization stability over epochs.
- **Data source**: `logs/train_curves.csv`
- **Plot type**: Mean line + uncertainty ribbon.
- **Caption must include**:
- smoothing rule if any,
- whether ribbon is std or CI,
- training/eval split.
- **Key observation**: Frozen Encoder shows larger oscillation after epoch 8.
- **Interpretation checklist**:
- Is instability transient or persistent?
- Does curve shape match final metric variance?
- Does this explain why one method is harder to tune?

View File

@@ -0,0 +1,36 @@
# Statistical Appendix
## Primary Metric
- Word Error Rate (WER), lower is better.
## Sample Structure
- Unit of analysis: seed-level run, paired by shared data split and subject pool.
- Number of seeds per condition: 5.
## Descriptive Statistics
| Condition | Mean WER | Std | 95% CI |
|---|---:|---:|---:|
| Full fine-tuning | 31.4 | 1.9 | [29.8, 33.0] |
| Subject Adapter | 33.2 | 1.3 | [32.1, 34.3] |
| Frozen Encoder | 37.0 | 2.1 | [35.1, 38.9] |
## Assumption Checks
- Shapiro-Wilk on paired differences: `p = 0.19`
- No strong evidence against normality for the primary contrast.
- Given small n, interpretation remains conservative.
## Inferential Tests
| Contrast | Test | Statistic | p | Effect size | Correction |
|---|---|---|---:|---:|---|
| Subject Adapter vs Frozen Encoder | paired t-test | `t(4) = -4.11` | 0.014 | Cohen's `d = 1.84` | Holm |
| Full fine-tuning vs Subject Adapter | paired t-test | `t(4) = -2.03` | 0.112 | Cohen's `d = 0.91` | Holm |
## Interpretation Guardrails
- First contrast is supported after correction.
- Second contrast trends in favor of full fine-tuning but is not conclusive at this sample size.
## Blockers / Limits
- No subject-level bootstrap yet.
- No calibration analysis available.

View File

@@ -0,0 +1,39 @@
# Analysis Depth Guide
Move beyond “method A > method B”.
## Four-layer depth ladder
### 1. Observation
What changed?
- absolute gap
- relative gap
- stability change
- subgroup pattern
### 2. Interpretation
What is the most defensible explanation?
- optimization stability
- inductive bias match
- subject/domain shift handling
- data scarcity sensitivity
### 3. Constraint
What prevents overclaiming?
- low sample size
- only one dataset
- missing subgroup coverage
- no robustness sweep
### 4. Decision
What should happen next?
- promote into durable result note
- run an ablation
- stop an unpromising branch
- update the active plan
## Good report sentence pattern
- “We observe X.”
- “This supports Y because Z evidence is present.”
- “However, the claim is bounded by A.”
- “Therefore the next decision is B.”

View File

@@ -0,0 +1,28 @@
# Common Pitfalls in Experimental Analysis
## Statistical pitfalls
- Reporting only the best run
- Mixing seed-level and subject-level units
- Running many contrasts without correction
- Reporting significance without effect size
- Using parametric tests after failed assumptions without explanation
## Visualization pitfalls
- No real figure despite readable data
- Plot without uncertainty information
- Overcrowded multi-panel figure with no message hierarchy
- Caption missing n / error-bar meaning
- Figure not referenced or interpreted in text
## Reasoning pitfalls
- Confusing correlation with mechanism
- Treating trend as conclusion
- Ignoring negative results
- Hiding instability behind a mean value
- Turning raw logs into durable conclusions too early
## Reporting pitfalls
- Writing paper prose before evidence is stabilized
- Mixing analysis artifact with final narrative artifact
- Not separating blocker from conclusion
- Forgetting to state what decision the analysis changes

View File

@@ -0,0 +1,30 @@
# Figure Interpretation Guide
A scientific figure is incomplete until the text answers:
1. why the figure exists,
2. what the reader should notice,
3. why that observation matters.
## Minimal interpretation block
For each figure, provide:
- **Purpose**: the research question this figure addresses
- **Observation**: the concrete pattern seen in the plot
- **Interpretation**: the mechanism or explanation supported by the evidence
- **Implication**: what decision, next experiment, or claim changes because of it
## Caption checklist
A usable caption should specify:
- what is plotted,
- what each axis means,
- sample size,
- what error bars / ribbons represent,
- any normalization or smoothing,
- any significance marker convention.
## Anti-patterns
- restating the axis labels as “interpretation”
- giving only aesthetic comments
- making causal claims unsupported by the plot
- repeating the caption without adding insight

View File

@@ -0,0 +1,561 @@
# Statistical Methods for ML/AI Experiments
完整的统计分析方法指南,用于 ML/AI 实验结果分析。
## 基础统计量
### 均值 (Mean)
**定义**: 所有观测值的平均值
**公式**: μ = (Σx) / n
**报告格式**: "模型在测试集上达到 85.3% 的准确率"
### 标准差 (Standard Deviation, SD)
**定义**: 衡量数据分散程度
**公式**: SD = √[Σ(x - μ)² / (n-1)]
**报告格式**: "准确率为 85.3% ± 2.1%(标准差)"
**何时使用**: 描述数据的变异性
### 标准误 (Standard Error, SE)
**定义**: 样本均值的标准差
**公式**: SE = SD / √n
**报告格式**: "准确率为 85.3% ± 0.7%(标准误)"
**何时使用**: 估计均值的不确定性
### 标准差 vs 标准误
| 特性 | 标准差 (SD) | 标准误 (SE) |
|------|------------|------------|
| 含义 | 数据的分散程度 | 均值估计的不确定性 |
| 随样本量变化 | 不变 | 减小(∝ 1/√n |
| 用途 | 描述数据变异 | 推断总体均值 |
| 报告场景 | 描述性统计 | 推断性统计 |
**重要**: 论文中必须明确说明使用的是标准差还是标准误。
### 置信区间 (Confidence Interval)
**定义**: 总体参数的可能范围
**95% 置信区间公式**: CI = μ ± t(α/2, n-1) × SE
**报告格式**: "准确率为 85.3% [95% CI: 83.9%, 86.7%]"
**解释**: 95% 的置信区间意味着如果重复实验多次95% 的区间会包含真实值。
## 预先检验(必须执行)
在进行参数检验前,必须验证数据是否满足检验的假设条件。
### 1. 正态性检验 (Normality Test)
**目的**: 验证数据是否服从正态分布
**何时需要**: 使用 t-test、ANOVA 等参数检验前
**常用方法**:
#### Shapiro-Wilk 检验
- **适用**: 样本量 n < 50
- **零假设**: 数据服从正态分布
- **判断**: p > 0.05 → 接受正态分布假设
- **使用场景**: 小样本,最常用
#### Kolmogorov-Smirnov 检验
- **适用**: 样本量 n ≥ 50
- **零假设**: 数据服从正态分布
- **判断**: p > 0.05 → 接受正态分布假设
- **使用场景**: 大样本
#### Anderson-Darling 检验
- **适用**: 所有样本量
- **优点**: 对尾部偏离更敏感
- **使用场景**: 需要检测尾部异常时
#### Q-Q 图 (Quantile-Quantile Plot)
- **类型**: 图形化方法
- **判断**: 点接近直线 → 正态分布
- **优点**: 直观展示偏离程度
- **使用场景**: 配合数值检验使用
**不满足正态性时的处理**:
1. 数据转换log, sqrt, Box-Cox
2. 使用非参数检验Wilcoxon, Mann-Whitney U
3. 增加样本量(中心极限定理)
### 2. 方差齐性检验 (Homogeneity of Variance)
**目的**: 验证多组数据的方差是否相等
**何时需要**: 使用独立样本 t-test、ANOVA 前
**常用方法**:
#### Levene 检验
- **适用**: 最常用,对非正态分布鲁棒
- **零假设**: 各组方差相等
- **判断**: p > 0.05 → 接受方差齐性假设
- **使用场景**: 默认选择
#### Bartlett 检验
- **适用**: 数据严格正态分布时
- **零假设**: 各组方差相等
- **判断**: p > 0.05 → 接受方差齐性假设
- **使用场景**: 正态性已验证
#### Brown-Forsythe 检验
- **适用**: Levene 检验的改进版
- **优点**: 对非正态分布更鲁棒
- **使用场景**: 数据明显偏态时
**不满足方差齐性时的处理**:
1. 使用 Welch's t-test不假设方差相等
2. 使用 Welch's ANOVA
3. 数据转换
4. 使用非参数检验
### 3. 独立性检验
**目的**: 验证观测值之间是否独立
**何时需要**: 所有统计检验前
**常见违反独立性的情况**:
- 时间序列数据(自相关)
- 重复测量(同一对象多次测量)
- 聚类数据(同一组内的观测)
**处理方法**:
- 时间序列:使用时间序列分析方法
- 重复测量:使用配对检验或混合效应模型
- 聚类数据:使用多层模型或聚类标准误
### 4. 异常值检测
**目的**: 识别和处理极端值
**常用方法**:
#### IQR 方法
- **定义**: 异常值 = Q1 - 1.5×IQR 或 Q3 + 1.5×IQR 之外
- **使用场景**: 最常用,简单直观
#### Z-score 方法
- **定义**: |Z| > 3 为异常值
- **使用场景**: 数据近似正态分布
#### Grubbs 检验
- **适用**: 检测单个异常值
- **使用场景**: 正态分布数据
**处理异常值**:
1. 检查是否为数据错误
2. 报告异常值的存在
3. 进行敏感性分析(有/无异常值)
4. 使用鲁棒统计方法
## 预先检验决策树
```
开始
样本量 < 30
↓ 是
检查正态性Shapiro-Wilk
↓ 不满足
使用非参数检验
↓ 否
检查正态性K-S 或 Q-Q 图)
↓ 满足
两组比较?
↓ 是
检查方差齐性Levene
↓ 满足
独立样本 t-test
↓ 不满足
Welch's t-test
↓ 否
多组比较?
↓ 是
检查方差齐性Levene
↓ 满足
ANOVA
↓ 不满足
Welch's ANOVA
```
## 预先检验报告模板
**论文中应报告**:
"在进行参数检验前,我们使用 Shapiro-Wilk 检验验证了数据的正态性(方法 A: W = 0.96, p = 0.23; 方法 B: W = 0.95, p = 0.18),使用 Levene 检验验证了方差齐性F = 1.23, p = 0.31)。所有检验均满足参数检验的假设条件。"
**如果不满足假设**:
"Shapiro-Wilk 检验显示数据不满足正态性假设(方法 A: W = 0.87, p = 0.01),因此我们使用非参数的 Mann-Whitney U 检验进行比较。"
## 假设检验(参数检验)
### 1. t-test两组对比
**用途**: 比较两个方法的性能差异
**假设条件**:
- 数据服从正态分布
- 方差齐性(独立样本 t-test
- 观测值独立
#### 独立样本 t-test (Independent Samples t-test)
**使用场景**: 比较两个独立组的均值
- 例:方法 A vs 方法 B 在不同数据集上的性能
**假设**:
- H₀: μ₁ = μ₂(两组均值相等)
- H₁: μ₁ ≠ μ₂(两组均值不等)
**报告格式**: "方法 A (85.3% ± 2.1%) 显著优于方法 B (82.1% ± 1.8%), t(18) = 3.45, p = 0.003"
**何时使用**: ✅ 两个独立组,满足正态性和方差齐性
#### 配对样本 t-test (Paired Samples t-test)
**使用场景**: 比较同一组对象在两种条件下的表现
- 例:同一数据集上,方法 A vs 方法 B 的性能
**假设**:
- H₀: μd = 0差值的均值为0
- H₁: μd ≠ 0差值的均值不为0
**报告格式**: "在10个数据集上方法 A 显著优于方法 B, t(9) = 4.23, p = 0.002"
**何时使用**: ✅ 配对数据,同一对象的前后对比
#### Welch's t-test
**使用场景**: 两组方差不相等时
-方差齐性检验不通过Levene's test p < 0.05
**优点**: 不假设方差相等,更鲁棒
**报告格式**: "方法 A 显著优于方法 B, Welch's t(16.3) = 3.21, p = 0.005"
**何时使用**: ✅ 方差齐性检验失败时的替代方案
### 2. ANOVA多组对比
**用途**: 同时比较三个或更多方法
**假设条件**:
- 数据服从正态分布
- 方差齐性
- 观测值独立
#### 单因素 ANOVA (One-Way ANOVA)
**使用场景**: 比较多个独立组的均值
- 例:方法 A vs B vs C vs D 的性能对比
**假设**:
- H₀: μ₁ = μ₂ = μ₃ = ... = μk所有组均值相等
- H₁: 至少有一组均值不同
**报告格式**: "不同方法之间存在显著差异, F(3, 36) = 8.45, p < 0.001"
**何时使用**: ✅ 三个或更多独立组
**重要**: ANOVA 只告诉你"至少有一组不同",需要事后检验找出具体哪些组不同。
#### 重复测量 ANOVA (Repeated Measures ANOVA)
**使用场景**: 同一组对象在多个条件下的表现
- 例:同一数据集上,多个方法的性能对比
**假设**:
- H₀: 所有条件下的均值相等
- H₁: 至少有一个条件的均值不同
**报告格式**: "不同方法之间存在显著差异, F(3, 27) = 12.34, p < 0.001"
**何时使用**: ✅ 配对数据,多个条件的对比
#### 双因素 ANOVA (Two-Way ANOVA)
**使用场景**: 研究两个因素的影响及其交互作用
-方法类型因素1× 数据集大小因素2对性能的影响
**报告格式**:
- "方法类型主效应显著, F(2, 54) = 15.23, p < 0.001"
- "数据集大小主效应显著, F(2, 54) = 8.91, p < 0.001"
- "交互作用不显著, F(4, 54) = 1.23, p = 0.31"
**何时使用**: ✅ 研究多个因素及其交互作用
#### Welch's ANOVA
**使用场景**: 方差不齐时的 ANOVA 替代方案
**报告格式**: "不同方法之间存在显著差异, Welch's F(3, 18.5) = 7.89, p = 0.002"
**何时使用**: ✅ 方差齐性检验失败时
### 3. 事后检验 (Post-hoc Tests)
**目的**: ANOVA 显著后,找出具体哪些组不同
**常用方法**:
#### Tukey HSD (Honestly Significant Difference)
**使用场景**: ANOVA 后的标准事后检验
- **优点**: 控制家族错误率
- **适用**: 各组样本量相等或接近
- **报告**: "Tukey HSD 检验显示,方法 A 显著优于方法 B (p = 0.003) 和方法 C (p = 0.012)"
**何时使用**: ✅ 默认选择,最常用
#### Bonferroni 校正
**使用场景**: 保守的事后检验
- **优点**: 简单,控制家族错误率
- **缺点**: 过于保守
- **报告**: "Bonferroni 校正后,方法 A 显著优于方法 B (p = 0.002)"
**何时使用**: ✅ 需要严格控制 Type I 错误时
#### Scheffé 检验
**使用场景**: 最保守的事后检验
- **优点**: 适用于所有对比(包括复杂对比)
- **缺点**: 功效最低
- **报告**: "Scheffé 检验显示,方法 A 显著优于方法 B (p = 0.015)"
**何时使用**: ✅ 需要进行复杂对比时
#### Dunnett 检验
**使用场景**: 多个实验组与一个对照组比较
- **优点**: 专门设计用于与对照组比较
- **报告**: "Dunnett 检验显示,方法 A、B、C 均显著优于基线方法 (p < 0.01)"
**何时使用**: ✅ 有明确的对照组(基线方法)时
## 假设检验(非参数检验)
**何时使用非参数检验**:
- 数据不满足正态分布假设
- 样本量很小n < 30
- 数据为序数或等级数据
- 存在明显的异常值
### 4. Wilcoxon 检验(配对数据)
**用途**: 配对数据的非参数检验t-test 的非参数替代
**使用场景**: 同一数据集上,两个方法的性能对比
-10个数据集上方法 A vs 方法 B
**假设**:
- H₀: 两组的中位数相等
- H₁: 两组的中位数不等
**报告格式**: "Wilcoxon 符号秩检验显示,方法 A 显著优于方法 B, Z = 2.81, p = 0.005"
**何时使用**: ✅ 配对数据,不满足正态性假设
### 5. Mann-Whitney U 检验(独立数据)
**用途**: 独立样本的非参数检验,独立样本 t-test 的非参数替代
**使用场景**: 两个独立组的性能对比
- 例:方法 A 在数据集1上 vs 方法 B 在数据集2上
**假设**:
- H₀: 两组的分布相同
- H₁: 两组的分布不同
**报告格式**: "Mann-Whitney U 检验显示,方法 A 显著优于方法 B, U = 45, p = 0.012"
**何时使用**: ✅ 独立样本,不满足正态性假设
**别名**: Wilcoxon 秩和检验
### 6. Kruskal-Wallis 检验(多组对比)
**用途**: 多组独立样本的非参数检验ANOVA 的非参数替代
**使用场景**: 三个或更多方法的性能对比
- 例:方法 A vs B vs C vs D
**假设**:
- H₀: 所有组的分布相同
- H₁: 至少有一组的分布不同
**报告格式**: "Kruskal-Wallis 检验显示,不同方法之间存在显著差异, H(3) = 15.23, p = 0.002"
**何时使用**: ✅ 多组独立样本,不满足正态性假设
**事后检验**: Dunn 检验(带 Bonferroni 校正)
### 7. Friedman 检验(重复测量)
**用途**: 配对数据的多组非参数检验,重复测量 ANOVA 的非参数替代
**使用场景**: 同一数据集上,多个方法的性能对比
-10个数据集上方法 A vs B vs C vs D
**假设**:
- H₀: 所有条件下的分布相同
- H₁: 至少有一个条件的分布不同
**报告格式**: "Friedman 检验显示,不同方法之间存在显著差异, χ²(3) = 18.45, p < 0.001"
**何时使用**: ✅ 配对数据,多组对比,不满足正态性假设
**事后检验**: Nemenyi 检验或 Wilcoxon 符号秩检验(带 Bonferroni 校正)
### 8. Sign 检验
**用途**: 最简单的配对数据非参数检验
**使用场景**: 只关心方向(哪个更好),不关心差异大小
- 例:方法 A 在多少个数据集上优于方法 B
**假设**:
- H₀: 正负差异的数量相等
- H₁: 正负差异的数量不等
**报告格式**: "Sign 检验显示,方法 A 在 10 个数据集中的 8 个上优于方法 B, p = 0.055"
**何时使用**: ✅ 只关心胜负,不关心差异大小
**优点**: 最鲁棒,对异常值不敏感
**缺点**: 功效最低
## 统计检验选择流程图
```
数据类型?
配对数据?
↓ 是
两组对比?
↓ 是
正态性检验
↓ 满足
配对 t-test
↓ 不满足
Wilcoxon 符号秩检验
↓ 否(多组)
正态性检验
↓ 满足
重复测量 ANOVA
↓ 不满足
Friedman 检验
↓ 否(独立数据)
两组对比?
↓ 是
正态性检验
↓ 满足
方差齐性检验
↓ 满足
独立 t-test
↓ 不满足
Welch's t-test
↓ 不满足
Mann-Whitney U 检验
↓ 否(多组)
正态性检验
↓ 满足
方差齐性检验
↓ 满足
ANOVA + 事后检验
↓ 不满足
Welch's ANOVA + Games-Howell
↓ 不满足
Kruskal-Wallis + Dunn 检验
```
## 多重比较校正
**问题**: 多次检验增加 Type I 错误(假阳性)概率
**公式**: P(至少一次错误) = 1 - (1-α)^k其中 k 为检验次数
**常用方法**:
| 方法 | 公式 | 保守程度 | 使用场景 |
|------|------|----------|----------|
| Bonferroni | α' = α/k | 最保守 | 少量检验 |
| Holm-Bonferroni | 逐步校正 | 较保守 | 中等数量检验 |
| FDR (Benjamini-Hochberg) | 控制错误发现率 | 较宽松 | 大量检验,探索性分析 |
## 效应量
**定义**: 衡量差异的实际大小,独立于样本量
**常用指标**:
| 效应量 | 适用场景 | 解释 |
|--------|----------|------|
| Cohen's d | t-test | \|d\| < 0.2 小0.2-0.5 中≥0.8 大 |
| η² (Eta squared) | ANOVA | 0.01 小0.06 中0.14 大 |
| r (相关系数) | 非参数检验 | 0.1 小0.3 中0.5 大 |
**报告**: 必须同时报告 p-value 和效应量
## 实验设计要点
**重复次数**: 最少 3-5 次,推荐 5-10 次,高方差任务 10+ 次
**随机种子**: 报告所有使用的随机种子,确保可重现
**交叉验证**: k-fold (k=5 或 10) 用于评估泛化性能
## 常见错误
1. **Cherry-picking**: 只报告最好结果 → 报告所有实验
2. **p-hacking**: 尝试多种分析找显著结果 → 预先确定方法
3. **混淆 SD 和 SE**: 不说明使用哪个 → 明确标注
4. **忽略多重比较**: 多次检验不校正 → 使用 Bonferroni/FDR
5. **只报告 p-value**: 缺少效应量 → 同时报告两者
## 报告检查清单
- [ ] 报告均值和标准差/标准误(明确标注)
- [ ] 报告实验重复次数
- [ ] 执行预先检验(正态性、方差齐性)
- [ ] 选择适当的统计检验
- [ ] 报告完整统计信息检验统计量、自由度、p-value
- [ ] 报告效应量
- [ ] 多重比较进行校正
- [ ] 说明随机种子设置
## 参考资源
- [Nature Statistics Checklist](https://www.nature.com/documents/nr-reporting-summary-flat.pdf)
- [ASA Statement on P-Values](https://www.amstat.org/asa/files/pdfs/p-valuestatement.pdf)
- [Reporting Statistics in Psychology](https://apastyle.apa.org/instructional-aids/numbers-statistics-guide.pdf)
## 总结
统计分析的核心原则:
1. **预先检验** - 验证假设条件
2. **完整报告** - 均值、标准差/标准误、样本量
3. **适当检验** - 根据数据特征选择方法
4. **多重校正** - 多次比较时校正 α
5. **效应量** - 不只报告 p-value
6. **可重现** - 提供足够细节
遵循这些原则可以确保实验结果的统计严谨性和可信度。

View File

@@ -0,0 +1,42 @@
# Statistical Reporting Standard
## Minimum reporting package
For every major comparison, report:
- metric definition and direction,
- unit of analysis,
- sample size / run count,
- descriptive statistics,
- uncertainty estimate,
- inferential test,
- effect size,
- correction strategy when multiple contrasts exist,
- limitation if assumptions or sample size are weak.
## Required fields
### Descriptive
- `mean ± std` when repeated runs are comparable
- `95% CI` when inference is discussed
- median / IQR when distribution is strongly non-normal
### Inferential
- exact test name
- test statistic and degrees of freedom when applicable
- p-value format
- effect size
- correction method for multiple comparisons
## Do not do these
- report only best run
- report only p-values
- hide non-significant comparisons
- treat unstable trends as conclusions
- switch tests without stating why
## Default wording rule
Use three layers:
1. **Observation** — what changed numerically
2. **Support** — what the test/effect size says
3. **Boundary** — what remains uncertain

View File

@@ -0,0 +1,269 @@
# Visualization Best Practices for ML/AI Papers
论文级可视化的最佳实践指南。
## 核心原则
1. **清晰性** - 信息传达清晰,无歧义
2. **准确性** - 数据表示准确,不误导
3. **可访问性** - 色盲友好,黑白打印可读
4. **专业性** - 符合学术出版标准
## 图表格式要求
### 矢量图 vs 位图
| 格式 | 类型 | 使用场景 | 质量 |
|------|------|----------|------|
| PDF/EPS | 矢量图 | 图表、曲线、示意图 | ✅ 推荐 |
| SVG | 矢量图 | 网页展示 | ✅ 可用 |
| PNG | 位图 | 照片、截图 | ⚠️ 需高分辨率≥600 DPI |
| JPG | 位图 | 照片 | ❌ 避免用于图表 |
**规则**: 所有图表使用矢量图格式PDF/EPS照片使用高分辨率位图PNG ≥600 DPI
## 配色方案
### 色盲友好配色
**推荐配色方案**:
#### Okabe-Ito 配色(最常用)
- 橙色: #E69F00
- 天蓝: #56B4E9
- 绿色: #009E73
- 黄色: #F0E442
- 蓝色: #0072B2
- 红色: #D55E00
- 粉色: #CC79A7
- 黑色: #000000
#### Paul Tol 配色
- 适用于定性数据
- 提供多种配色方案(亮色、柔和、对比)
### 配色原则
1. **最多使用 5-7 种颜色** - 过多颜色难以区分
2. **避免红绿组合** - 红绿色盲无法区分
3. **测试黑白打印** - 确保灰度下可读
4. **使用不同线型** - 配合颜色使用(实线、虚线、点线)
## 图表类型选择
### 折线图 (Line Plot)
**使用场景**: 展示趋势、训练曲线、时间序列
**要点**:
- 使用误差带(阴影区域)表示标准差/标准误
- 线宽 1.5-2.0 pt
- 标记点大小适中4-6 pt
- 网格线透明度 0.3
**示例**: 训练损失曲线、准确率随 epoch 变化
### 柱状图 (Bar Plot)
**使用场景**: 性能对比、消融实验
**要点**:
- 使用误差条表示不确定性
- 柱子宽度一致
- 间距适当(柱宽的 20-30%
- 加粗最佳结果的柱子
**示例**: 不同方法的准确率对比
### 箱线图 (Box Plot)
**使用场景**: 展示分布、识别异常值
**要点**:
- 显示中位数、四分位数、异常值
- 适合展示多次运行的结果
- 可与散点图叠加
**示例**: 多次运行的性能分布
### 散点图 (Scatter Plot)
**使用场景**: 展示相关性、聚类效果
**要点**:
- 点的大小和透明度适当
- 使用不同形状区分类别
- 添加趋势线(如需要)
**示例**: 预测值 vs 真实值、特征空间可视化
### 热力图 (Heatmap)
**使用场景**: 混淆矩阵、相关性矩阵、注意力权重
**要点**:
- 使用顺序配色(单色渐变)或发散配色(双色渐变)
- 添加数值标注(如空间允许)
- 色条colorbar清晰标注
**示例**: 混淆矩阵、注意力可视化
## 图表元素规范
### 坐标轴
**X 轴和 Y 轴**:
- 标签字体大小: 10-12 pt
- 刻度字体大小: 8-10 pt
- 标签清晰描述变量和单位
- 刻度间距合理
**坐标轴范围**:
- Y 轴通常从 0 开始(除非有特殊原因)
- 不要截断坐标轴夸大差异
- 使用科学计数法表示大数值
### 图例 (Legend)
**位置**: 不遮挡数据,通常放在右上角或外部
**内容**:
- 简洁描述每条曲线/柱子
- 字体大小 8-10 pt
- 使用与图中一致的颜色和线型
### 标题和标签
**图标题**: 通常不在图内添加标题,使用 caption 代替
**Caption**:
- 独立完整,不依赖正文
- 说明图表内容、实验设置、关键观察
- 字体大小 9-10 pt
**示例**: "图 1: 不同模型在测试集上的准确率对比。误差条表示 5 次运行的标准差。我们的方法(蓝色)在所有数据集上均优于基线方法。"
## 误差表示
### 误差条 (Error Bars)
**类型**:
- 标准差 (SD): 描述数据变异性
- 标准误 (SE): 描述均值不确定性
- 置信区间 (CI): 参数估计范围
**表示方法**:
- 柱状图: 垂直误差条
- 折线图: 误差带(阴影区域)
**必须说明**: 在 caption 中明确说明使用的是哪种误差
### 误差带 (Error Band)
**折线图的误差表示**:
- 使用半透明阴影区域alpha=0.2-0.3
- 颜色与主线一致
- 不要使用误差条(会使图表混乱)
## 尺寸和分辨率
### 图表尺寸
**单栏图** (single-column):
- 宽度: 3.5 inches (约 9 cm)
- 高度: 2-3 inches
**双栏图** (double-column):
- 宽度: 7 inches (约 18 cm)
- 高度: 3-5 inches
**纵横比**: 通常 4:3 或 16:9
### 分辨率
**矢量图**: 无需考虑分辨率
**位图**:
- 最低: 300 DPI
- 推荐: 600 DPI
- 高质量: 1200 DPI
## 常见错误
### 错误 1: 使用位图格式
**错误**: 保存为 PNG/JPG
**正确**: 保存为 PDF/EPS
### 错误 2: 非色盲友好配色
**错误**: 红色和绿色组合
**正确**: 使用 Okabe-Ito 配色
### 错误 3: 缺少误差表示
**错误**: 只显示均值
**正确**: 添加误差条/误差带
### 错误 4: 坐标轴截断
**错误**: Y 轴从 80% 开始(夸大差异)
**正确**: Y 轴从 0% 开始(或说明原因)
### 错误 5: 图表过于复杂
**错误**: 一张图包含 10+ 条曲线
**正确**: 拆分为多张图或使用子图
### 错误 6: 字体过小
**错误**: 标签字体 6 pt
**正确**: 标签字体 10-12 pt
## 检查清单
提交前检查:
- [ ] 使用矢量图格式PDF/EPS
- [ ] 配色色盲友好Okabe-Ito 或 Paul Tol
- [ ] 黑白打印可读(测试过)
- [ ] 包含误差条/误差带
- [ ] Caption 中说明误差类型
- [ ] 坐标轴标签清晰(包含单位)
- [ ] 图例不遮挡数据
- [ ] 字体大小适当≥8 pt
- [ ] 线宽适当1.5-2.0 pt
- [ ] Caption 独立完整
## 工具推荐
**Python**:
- matplotlib: 基础绘图
- seaborn: 统计可视化
- plotly: 交互式图表
**配色工具**:
- ColorBrewer: 配色方案选择
- Coblis: 色盲模拟器
**格式转换**:
- Inkscape: SVG 编辑和转换
- Adobe Illustrator: 专业图形编辑
## 参考资源
- [Ten Simple Rules for Better Figures](https://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1003833)
- [Okabe-Ito Color Palette](https://jfly.uni-koeln.de/color/)
- [Paul Tol's Notes on Colour](https://personal.sron.nl/~pault/)
## 总结
论文级可视化的关键:
1. **矢量图格式** - PDF/EPS
2. **色盲友好** - Okabe-Ito 配色
3. **误差表示** - 误差条/误差带
4. **清晰标注** - 坐标轴、图例、caption
5. **黑白可读** - 测试灰度打印
遵循这些原则可以创建清晰、准确、专业的论文图表。