Install any skill in seconds. Free to start, no credit card required.
Get Started Free →执行数值型数据的分布分析与异常值检测,支持通过正则表达式从文本中提取误差项并生成高分辨率的箱线图与直方图报告。
.claude/skills/opensensenova-statistical-distribution-and-outlier-analysis/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-14 | ✗→✓ | ▲ Improved | 33% | 0% |
| case-21 | ✗→✓ | ▲ Improved | 24% | 0% |
| case-22 | ✗→✓ | ▲ Improved | 24% | 0% |
| case-03 | ✓→✓ | = Same ✓ | -12% | 0% |
| case-04 | ✓→✓ | = Same ✓ | 94% | 0% |
Step 1 加载数据并进行预处理,配置中文字体与环境参数
pythonimport pandas as pd import matplotlib.pyplot as plt import numpy as np import seaborn as sns import re # 设置中文字体,兼容不同环境 plt.rcParams['font.sans-serif'] = ['SimHei', 'WenQuanYi Zen Hei', 'DejaVu Sans'] plt.rcParams['axes.unicode_minus'] = False # 加载数据并处理合并单元格 file_path = 'input_data.xlsx' df = pd.read_excel(file_path) df.ffill(inplace=True) # 处理可能的合并单元格空值 # 统一重命名列名以便于程序化处理 original_columns = df.columns.tolist() df.columns = [f'col_{i+1}' for i in range(df.shape[1])] print(f"数据形状: {df.shape}") print(f"原始列映射: {dict(zip(df.columns, original_columns))}")
Step 2 生成多子图箱线图,直观展示各维度数据的分布特征与统计量
python# 计算子图布局 num_cols = len(df.columns) rows = (num_cols + 2) // 3 fig, axes = plt.subplots(rows, 3, figsize=(18, 5 * rows)) fig.suptitle('数据分布维度分析', fontsize=16, fontweight='bold') axes_flat = axes.flatten() for i, column in enumerate(df.columns): data_series = df[column].dropna() if pd.api.types.is_numeric_dtype(data_series): axes_flat[i].boxplot(data_series, patch_artist=True, boxprops=dict(facecolor='lightblue', alpha=0.7), medianprops=dict(color='red', linewidth=2)) stats = data_series.describe() axes_flat[i].set_title(f'{column} (n={len(data_series)})', fontsize=12) axes_flat[i].text(0.05, 0.95, f'均值: {stats["mean"]:.2f}\n中位数: {stats["50%"]:.2f}', transform=axes_flat[i].transAxes, verticalalignment='top', bbox=dict(boxstyle='round', facecolor='white', alpha=0.8)) axes_flat[i].grid(True, alpha=0.3) plt.tight_layout(rect=[0, 0.03, 1, 0.95]) output_path = 'individual_boxplots.png' plt.savefig(output_path, dpi=300, bbox_inches='tight') plt.show()
Step 3 执行异常值检测算法,计算四分位距(IQR)并生成统计报告
pythonanalysis_results = [] for col in df.columns: data = df[col].dropna() if not pd.api.types.is_numeric_dtype(data): continue Q1 = data.quantile(0.25) Q3 = data.quantile(0.75) IQR = Q3 - Q1 lower_bound = Q1 - 1.5 * IQR upper_bound = Q3 + 1.5 * IQR outliers = data[(data < lower_bound) | (data > upper_bound)] analysis_results.append({ '维度': col, '样本量': len(data), '异常值数量': len(outliers), '偏度': round(data.skew(), 3), '峰度': round(data.kurtosis(), 3), '范围': f"{data.min():.2f} ~ {data.max():.2f}" }) report_df = pd.DataFrame(analysis_results) print("=== 数据质量与分布报告 ===") print(report_df.to_string(index=False))
Step 4 使用正则表达式从文本列中提取误差值(±模式)并进行量化分析
python# 假设 target_col 包含类似 "10.5 ± 0.2" 的文本 target_col = df.columns[0] text_data = df[target_col].astype(str).str.cat(sep=' ') # 正则表达式提取 ± 后面的数值 error_pattern = r'±(\d+\.?\d*)' extracted_errors = [float(val) for val in re.findall(error_pattern, text_data)] if extracted_errors: print(f"提取到误差样本量: {len(extracted_errors)}") print(f"误差均值: {np.mean(extracted_errors):.4f}") else: print("未在指定列中检测到符合 ± 模式的误差数据")
Step 5 绘制误差分布直方图,并标注核心统计参考线
pythonif extracted_errors: plt.figure(figsize=(10, 6)) # 自动计算 bins 数量 n, bins, patches = plt.hist(extracted_errors, bins='auto', color='skyblue', edgecolor='black', alpha=0.7) # 在柱体上方标注频次 for i in range(len(n)): if n[i] > 0: plt.text(bins[i] + (bins[i+1]-bins[i])/2, n[i] + 0.1, str(int(n[i])), ha='center', va='bottom', fontweight='bold') # 添加均值参考线 mean_val = np.mean(extracted_errors) plt.axvline(mean_val, color='red', linestyle='--', linewidth=2, label=f'误差均值: {mean_val:.3f}') plt.title('误差项分布特征直方图', fontsize=14) plt.xlabel('误差量级', fontsize=12) plt.ylabel('出现频次', fontsize=12) plt.legend() plt.grid(axis='y', alpha=0.3) plt.tight_layout() plt.savefig('error_distribution_histogram.png', dpi=300) plt.show()
Step 6 导出分析摘要并生成下载链接
pythonsummary_file = 'analysis_summary.csv' report_df.to_csv(summary_file, index=False, encoding='utf_8_sig') from IPython.display import FileLink print("分析完成,点击下方链接下载报告:") display(FileLink(summary_file)) display(FileLink('individual_boxplots.png'))
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→fail | 41,979 | 18,986 | -55% | 1 | 1 | 0% | 5,419 | 5,003 | -8% | 0 | 0 | — |
case-02 | fail→fail | 24,978 | 15,466 | -38% | 1 | 1 | 0% | 4,112 | 4,993 | +21% | 0 | 0 | — |
case-03 | pass→pass | 23,184 | 19,065 | -18% | 1 | 1 | 0% | 5,462 | 4,824 | -12% | 0 | 0 | — |
case-04 | pass→pass | 13,236 | 11,343 | -14% | 1 | 1 | 0% | 2,120 | 4,115 | +94% | 0 | 0 | — |
case-05 | pass→pass | 13,838 | 8,619 | -38% | 1 | 1 | 0% | 2,082 | 3,088 | +48% | 0 | 0 | — |
case-06 | pass→pass | 11,270 | 10,418 | -8% | 1 | 1 | 0% | 2,374 | 3,700 | +56% | 0 | 0 | — |
case-07 | pass→pass | 14,660 | 8,934 | -39% | 1 | 1 | 0% | 2,236 | 3,284 | +47% | 0 | 0 | — |
case-08 | pass→pass | 5,467 | 4,028 | -26% | 1 | 1 | 0% | 1,059 | 2,374 | +124% | 0 | 0 | — |
case-09 | pass→pass | 11,733 | 5,314 | -55% | 1 | 1 | 0% | 1,559 | 2,525 | +62% | 0 | 0 | — |
case-10 | pass→pass | 7,671 | 5,590 | -27% | 1 | 1 | 0% | 1,539 | 2,737 | +78% | 0 | 0 | — |
case-11 | pass→pass | 9,842 | 7,142 | -27% | 1 | 1 | 0% | 2,248 | 3,032 | +35% | 0 | 0 | — |
case-12 | pass→pass | 9,456 | 4,367 | -54% | 1 | 1 | 0% | 1,547 | 2,443 | +58% | 0 | 0 | — |
case-13 | pass→pass | 9,679 | 2,810 | -71% | 1 | 1 | 0% | 1,259 | 2,095 | +66% | 0 | 0 | — |
case-14 | fail→pass | 9,583 | 3,184 | -67% | 1 | 1 | 0% | 1,640 | 2,176 | +33% | 0 | 0 | — |
case-15 | fail→fail | 16,608 | 8,164 | -51% | 1 | 1 | 0% | 2,078 | 2,847 | +37% | 0 | 0 | — |
case-16 | pass→pass | 17,577 | 9,674 | -45% | 1 | 1 | 0% | 2,630 | 3,625 | +38% | 0 | 0 | — |
case-17 | pass→pass | 13,202 | 12,132 | -8% | 1 | 1 | 0% | 2,533 | 3,922 | +55% | 0 | 0 | — |
case-18 | pass→pass | 4,953 | 8,373 | +69% | 1 | 1 | 0% | 912 | 2,901 | +218% | 0 | 0 | — |
case-19 | pass→pass | 9,974 | 3,600 | -64% | 1 | 1 | 0% | 1,179 | 2,228 | +89% | 0 | 0 | — |
case-20 | pass→pass | 4,439 | 3,929 | -11% | 1 | 1 | 0% | 524 | 2,059 | +293% | 0 | 0 | — |
case-21 | fail→pass | 9,311 | 1,845 | -80% | 1 | 1 | 0% | 1,518 | 1,883 | +24% | 0 | 0 | — |
case-22 | fail→pass | 8,245 | 2,003 | -76% | 1 | 1 | 0% | 1,574 | 1,952 | +24% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +14 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.