mcpField
S
stat-eda

stat-eda

github.com/asgard-ai-platform数据与数据库24335 次安装21 周前更新
代码仓库

关于 stat-eda

stat-eda 是用于探索性数据分析的技能,面向分析师和建模人员,强调先划分训练集与测试集,再仅用训练集探索,以减少信息泄漏。它还提示检查缺失机制、分组趋势和可疑特征。

主要功能

  1. 01划分数据集后再开展 EDA
  2. 02检查缺失数据模式
  3. 03按混杂因素分层核查趋势
  4. 04标记可能泄漏的特征

适用场景

  1. 01在建模前探索训练数据
  2. 02判断缺失值是否随机
  3. 03核实总体趋势是否受子组影响
  4. 04排查与目标变量高度相关的特征

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/asgard-ai-platform/skills --skill stat-eda

安装后在 Claude Code 中输入/stat-eda确认已加载。

附带文件examples/sample_scenario.mdreferences/missing-data.md

详细介绍

探索性数据分析(EDA)

框架

IRON LAW: Perform EDA Only AFTER Train/Test Split — Or You Leak the Future

Agents know "do EDA first." But they almost always do EDA on the FULL
dataset before splitting. This is information leakage: you've seen the
test set's distributions, outliers, and correlations, and your subsequent
modeling choices (feature scaling, outlier treatment, imputation strategy)
are now informed by data the model shouldn't see. Split first, then EDA
only on the training set. Apply the same transformations to the test set
without re-examining it.

Exception: data quality checks (nulls, dtypes, duplicates) CAN run on
the full dataset since they don't inform model hyperparameters.
EDA 工作流

标准的五阶段流程(结构 → 质量 → 单变量 → 双变量 → 结果总结)。假设 Agent 已经了解这些步骤。请重点关注以下容易忽略的陷阱。

许多 EDA 指南都会漏掉的关键补充:

  1. 先划分,再探索(参见上文的铁律)
  2. 缺失数据的模式比数量更重要:MCAR 可安全地进行插补;MNAR(例如,高收入受访者跳过收入问题)需要进行领域建模,而非用均值填充
  3. 检查辛普森悖论:如果某个趋势在汇总数据中成立,但在子群体中反转,那么汇总趋势就具有误导性。在报告双变量发现之前,务必按最明显的混杂因素分层
  4. 特征中的数据泄漏:与目标变量完全相关的特征通常是由目标变量推导而来的(例如,用“refund_amount”预测客户流失——它是结果,而不是原因)。对于任何 r > 0.95 的特征,都应标记出来进行因果审查

可视化选择指南请参见 references/missing-data.md。

输出格式

# EDA Report: {Dataset Name}

## Dataset Overview
- Rows: {N}, Columns: {N}
- Date range: {if applicable}
- Key columns: {description}

## Data Quality
| Issue | Columns Affected | Count/% | Action |
|-------|-----------------|---------|--------|
| Missing values | {cols} | {N / %} | {drop / impute / investigate} |
| Outliers | {cols} | {N} | {cap / remove / keep} |
| Duplicates | — | {N} | {remove} |

## Key Statistics
| Variable | Mean | Median | Std | Min | Max | Distribution |
|----------|------|--------|-----|-----|-----|-------------|
| {var} | ... | ... | ... | ... | ... | {normal/skewed/bimodal} |

## Key Findings
1. {insight with supporting data}
2. {insight}
3. {insight}

## Recommendations
- {next analysis step or data issue to resolve}

注意事项

  • 相关性 ≠ 因果关系:EDA 用于发现关联。要确立因果关系,需要进行受控实验或采用因果推断方法。
  • 异常值可能是数据错误,也可能是真实信号:不要自动删除。应进行调查。一笔金额为 $1M 的交易可能是笔误,也可能来自你最大的客户。
  • 缺失数据具有意义:某一列中的缺失数据可能与另一列中的值有关。“收入缺失”可能意味着“失业”,而不是随机缺失。请检查其中的模式。
  • 可视化会误导:截断 Y 轴、挑选时间范围和使用误导性刻度都可能扭曲洞见。务必使用合适的刻度,并说明局限性。

参考资料

  • 有关缺失数据处理策略,请参见 references/missing-data.md

评论

支持 Markdown