inference-decision
Skill0 starsChanged 4 months agoMITView on GitHub
當用戶跑完統計分析後需要解讀結果、判斷實務意義、並要求「這個 p 值意味什麼/效應量夠大嗎/樣本量夠不夠/該做什麼決策」時觸發。讀上游 7 個統計 skill 的 `tmp_data/r_output.json` 中間產物,做顯著性判定 + 效應量分級 + Bayes 因子近似 + 功率分析,並產出研究/商業雙取向決策建議的 Word 報告。 EN: Use AFTER any upstream stats skill has produced `tmp_data/r_output.json` and the user wants interpretation — "what does this p-value mean", "is the effect big enough", "do I have enough power", "should I ship / reject / keep testing". Combines significance × effect-size grading × Bayes-factor approximation × post-hoc power into a research-and-business decision docx.
In this repository9 other files it gives its agents.
- advanced-data-analyticsSkill
- data-preparationSkill
- factor-analysisSkill
- factorial-anovaSkill
- literature-reviewSkill
- multivariate-analysisSkill
- regression-analyticsSkill
- survival-analysisSkill
- time-series-analysisSkill
The file
Files
Skill: inference-decision
流水線終端:把上游統計分析的數字翻譯為推斷結論與決策建議。
Metadata
- Description: 從 7 個統計 skill 的
tmp_data/r_output.json讀取中間結果 → 統一到 NormalizedResult schema → 執行深度統計推斷(p vs α + 效應量分級 + Bayes 因子近似 + 功率分析 + 樣本量建議)→ 生成雙取向決策建議(研究 + 商業)→ 交付 Word 報告。不重跑分析,只做推斷。 - Version: 1.0.0
- Entrypoint:
orchestrator.py(CLI:--input-json <path>或--from-skill <name>) - Related(上游輸入源):
advanced-data-analytics(t-test / ANOVA / chi² / correlation)regression-analytics(linear / logistic)factor-analysis(EFA / CFA)factorial-anova(多因子 ANOVA)multivariate-analysis(PCA / cluster / MANOVA)survival-analysis(KM / Cox)time-series-analysis(decompose / ARIMA / anomaly / VAR)
- Related(同層工具):
data-preparation(清洗原始數據)literature-review(背景研究)
觸發時機
- 「這個 p 值 = 0.03 到底意味什麼?」
- 「效應量夠大嗎?該不該相信這個結果?」
- 「幫我判斷這次 A/B 測試該不該上線」
- 「樣本量夠不夠?要不要繼續收數據?」
- 「幫我做貝葉斯因子解讀 / power analysis」
- 「這個模型的實務意義是什麼?」
- 「給我一份決策報告」
使用模式
模式 A:從指定 skill 自動讀取
python orchestrator.py --from-skill advanced-data-analytics \
--alpha 0.05 --target-power 0.8 --context both \
--output-dir ./outcome-temp/inference--from-skill 會自動從對應 skill 的 tmp_data/r_output.json 讀取。
模式 B:顯式指定 JSON 路徑
python orchestrator.py --input-json <path-to-r_output.json> \
--context business --output-dir <out>模式 C:完整流水線串接
用戶想從清洗到推斷一條龍:
data-preparation → regression-analytics → inference-decision每一步的 CLI 都在上游 docx 末尾自動附上;本 skill 是最後一環。
SOP(Claude 自我遵循)
- 定位輸入
- 若用戶提供
--input-json,直接用 - 若用戶說「幫我解讀 XX 分析結果」,識別對應 skill 名,用
--from-skill - 若模糊,掃描 8 個 skill 的
tmp_data/r_output.json,選最新的並確認
- 若用戶提供
- 規範化:
result_loader.load(json_path)→NormalizedResult- 自動識別 source_skill(依 JSON 頂層 keys)
- 提取所有
primary_tests(每個主檢驗或係數各一項)
- 推斷:
inference_engine.analyze(normalized_result, alpha, target_power)- 每個 test:顯著性判定 + 效應量分級 + Bayes 因子近似 + 當前功率 + 達 target power 所需 n
- 決策:
decision_advisor.advise(inference_result, context)- 依 context =
research/business/both生成建議 - 附 2×2 決策象限(顯著性 × 效應量)
- 依 context =
- 交付:
word_generator.generate_docx()產出
Output Location
預設輸出目錄:./outcome-temp/
Inference_Decision_Report.docx:完整推斷 + 決策報告- 章節:
- 原始分析摘要(source skill / analysis / n)
- 推斷結果表格(每 term 一行:估計 / p / α / 效應量 / 等級 / BF₁₀ / 功率)
- 假設檢驗診斷(正態、同方差、共線性等 —— 若上游提供)
- 樣本量建議(當前功率 + 達 target power 所需 n)
- 決策象限(2×2 可視化文字)
- 研究建議(context in {research, both} 時)
- 商業建議(context in {business, both} 時)
- 警告與保留意見
效應量分級標準
| 指標 | Negligible | Small | Medium | Large |
| Cohen's d | |d| < 0.2 | 0.2 - 0.5 | 0.5 - 0.8 | > 0.8 |
| Correlation r | |r| < 0.1 | 0.1 - 0.3 | 0.3 - 0.5 | > 0.5 |
| Partial η² | < 0.01 | 0.01 - 0.06 | 0.06 - 0.14 | > 0.14 |
| Cramér's V | < 0.1 | 0.1 - 0.3 | 0.3 - 0.5 | > 0.5 |
| R² (regression) | < 0.02 | 0.02 - 0.13 | 0.13 - 0.26 | > 0.26 |
| Hazard Ratio | |log HR| < 0.2 | 0.2 - 0.5 | 0.5 - 1.0 | > 1.0 |
Bayes 因子分級(BF₁₀)
| 範圍 | 解讀 |
| < 1/10 | Strong evidence for H0 |
| 1/10 – 1/3 | Moderate evidence for H0 |
| 1/3 – 3 | Inconclusive |
| 3 – 10 | Moderate evidence for H1 |
| > 10 | Strong evidence for H1 |
用 BIC 近似:BF₁₀ ≈ exp((BIC_null - BIC_alt) / 2)。無 rstan 依賴。
決策象限(2×2)
| 效應量 small/negligible | 效應量 medium/large | |
| 顯著 (p < α) | CAUTION(大樣本 inflate?) | GO(推薦行動) |
| 不顯著 (p ≥ α) | NO GO(無效應) | MORE DATA(樣本不足) |
Constraints
- 只讀取
r_output.json,不重跑分析 - Bayes 因子是 BIC 近似值,不是精確後驗;只用於粗粒度判定
- 功率分析目前支援 t-test / ANOVA / correlation / regression;其他分析類型會標「不適用」而不強行計算
- 效應量分級閾值遵循 Cohen (1988) 慣例,可能不適合所有領域(如醫學藥效常用更嚴格閾值)
- 若上游 warnings 提示假設違反,推斷結論會加保留意見
Dependencies
- Python 3.10+:
scipy>=1.10 statsmodels>=0.14 python-docx>=1.0 numpy pandas - 無 R 依賴
Failure Modes(Claude 遇到時的應對)
- 找不到
r_output.json→ 提示用戶先跑上游統計 skill;列出所有已存在的tmp_data/r_output.json路徑 - JSON 結構無法識別 → 提示可能是舊版格式;建議重跑上游 skill 生成新 JSON
- 無主要檢驗(如 factor-analysis 的 EFA) → 只做描述性報告(因子數、KMO、載荷),不做顯著性推斷
- effect_size 為 None → 只做顯著性判定,效應量段落標記「上游未提供」
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

