关于 data-analysis
data-analysis 是指导统计分析的 Agent Skills™ 技能,涵盖数据导入、清理、检验和可视化。它面向可复现的研究与分析,强调检查检验假设并制作适合发表的图表。
主要功能
- 01数据导入与清理
- 02探索性与统计分析
- 03检查统计检验假设
- 04报告效应量
- 05制作发表级可视化
适用场景
- 01分析实验或观察数据
- 02清理供后续分析的数据集
- 03在检查假设后执行假设检验
- 04制作适合期刊投稿的图表
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ itallstartedwithaidea/ agent-skills --skill data-analysis安装后在 Claude Code 中输入/data-analysis确认已加载。
详细介绍
数据分析
属于 Agent Skills™,由 googleadsagent.ai™ 提供
描述
数据分析提供了一个使用 pandas、numpy 和 scipy 进行统计分析的结构化框架,并通过 matplotlib、seaborn 和 plotly 实现可视化。Agent 遵循严谨的流程,从数据导入和清理,到探索性分析、统计检验和出版级可视化,并确保每一步都可复现。
科学数据分析不是探索性编码,而是一项有纪律的工作:每次数据转换都有依据,每项统计检验都经过假设验证,每张可视化图表都能准确呈现底层数据。这项技能通过要求 Agent 记录数据来源、在应用参数检验前验证分布,并在报告 p 值的同时报告效应量,来贯彻这一原则。
可视化层生成适用于期刊投稿的图表:恰当的坐标轴标签和单位、色盲友好型调色板、适用于单栏或双栏排版的合适图表尺寸,以及矢量输出格式(SVG、PDF)。探索性工作使用交互式 plotly 可视化;出版用静态图表则使用 matplotlib/seaborn 生成。
适用场景
- 对实验数据或观察数据进行统计分析
- 清理和转换数据集,以供后续分析使用
- 创建出版级图表
- 在适当检查假设后进行假设检验
- 对新数据集进行探索性数据分析
- 构建可复现的分析流程
工作原理
graph TD
A[Raw Data] --> B[Ingest + Validate Schema]
B --> C[Clean: Missing Values, Outliers, Types]
C --> D[Exploratory Data Analysis]
D --> E[Distribution Assessment]
E --> F{Parametric Assumptions Met?}
F -->|Yes| G[Parametric Tests]
F -->|No| H[Non-Parametric Tests]
G --> I[Effect Size + Confidence Intervals]
H --> I
I --> J[Publication Visualization]
J --> K[Reproducible Report]
该流程会在选择检验方法前强制检查假设。参数检验(t 检验、ANOVA)要求数据满足正态性和方差齐性;如果假设不成立,Agent 会自动选择非参数替代方法(Mann-Whitney、Kruskal-Wallis)。
实现
import pandas as pd
import numpy as np
from scipy import stats
import seaborn as sns
import matplotlib.pyplot as plt
def analysis_pipeline(filepath: str) -> dict:
df = pd.read_csv(filepath)
report = {
"shape": df.shape,
"missing": df.isnull().sum().to_dict(),
"dtypes": df.dtypes.astype(str).to_dict(),
}
numeric_cols = df.select_dtypes(include=[np.number]).columns
for col in numeric_cols:
stat, p = stats.shapiro(df[col].dropna()[:5000])
report[f"{col}_normality"] = {"statistic": stat, "p_value": p, "normal": p > 0.05}
return report
def compare_groups(df: pd.DataFrame, value_col: str, group_col: str) -> dict:
groups = [g[value_col].dropna() for _, g in df.groupby(group_col)]
normality_ok = all(stats.shapiro(g[:5000]).pvalue > 0.05 for g in groups)
_, levene_p = stats.levene(*groups)
homoscedastic = levene_p > 0.05
if normality_ok and homoscedastic:
stat, p = stats.f_oneway(*groups) if len(groups) > 2 else stats.ttest_ind(*groups)
test_name = "ANOVA" if len(groups) > 2 else "t-test"
else:
stat, p = stats.kruskal(*groups)
test_name = "Kruskal-Wallis"
effect = compute_cohens_d(groups[0], groups[1]) if len(groups) == 2 else compute_eta_squared(groups)
return {"test": test_name, "statistic": stat, "p_value": p, "effect_size": effect}
def publication_figure(df: pd.DataFrame, x: str, y: str, output: str):
fig, ax = plt.subplots(figsize=(3.5, 3)) # Single-column journal width
sns.boxplot(data=df, x=x, y=y, palette="colorblind", ax=ax)
ax.set_xlabel(x.replace("_", " ").title())
ax.set_ylabel(y.replace("_", " ").title())
sns.despine()
fig.tight_layout()
fig.savefig(output, dpi=300, bbox_inches="tight")
plt.close(fig)
最佳实践
- 选择参数检验前,务必检查正态性和方差齐性
- 报告 p 值时,同时报告效应量(Cohen's d、eta-squared)——不说明效应大小的显著性毫无意义
- 所有可视化都使用色盲友好型调色板(
colorblind、viridis) - 对所有随机操作设置随机种子,以确保结果可复现
- 使用内联注释记录每次数据转换,并说明原因
- 出版时将图表导出为矢量格式(SVG、PDF);用于网页时则导出为光栅格式(PNG)
平台兼容性
| 平台 | 支持情况 | 说明 |
|---|---|---|
| Cursor | 完全支持 | Jupyter + Python 执行 |
| VS Code | 完全支持 | 支持 Jupyter notebook |
| Windsurf | 完全支持 | Python 环境 |
| Claude Code | 完全支持 | 脚本执行 |
| Cline | 完全支持 | 数据分析工作流 |
| aider | 部分支持 | 仅代码生成 |
相关技能
关键词
data-analysis statistics pandas scipy visualization matplotlib seaborn hypothesis-testing publication-figures
© 2026 googleadsagent.ai™ | Agent Skills™ | MIT License