Install any skill in seconds. Free to start, no credit card required.
Get Started Free →执行全面的异常值检测与数据质量评估,利用 IQR 方法识别异常值并结合偏度、峰度分析数据分布特征,适用于非正态分布数据的预处理阶段。
.claude/skills/opensensenova-outlier-detection-and-quality-assessment/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-09 | ✗→✓ | ▲ Improved | 72% | 0% |
| case-14 | ✗→✓ | ▲ Improved | 110% | 0% |
| case-15 | ✗→✓ | ▲ Improved | 100% | 0% |
| case-16 | ✗→✓ | ▲ Improved | -10% | 0% |
| case-17 | ✗→✓ | ▲ Improved | 55% | 0% |
pythonimport pandas as pd import matplotlib.pyplot as plt import numpy as np import seaborn as sns # 设置中英文字体以支持可视化显示 (SimHei 或 WenQuanYi) plt.rcParams['font.sans-serif'] = ['SimHei', 'WenQuanYi Zen Hei', 'DejaVu Sans'] plt.rcParams['axes.unicode_minus'] = False # 加载数据 file_path = 'data.xlsx' # 替换为实际文件路径 df = pd.read_excel(file_path) # 基础信息检查 print(f"数据形状: {df.shape}") print(f"数据类型:\n{df.dtypes}") print(df.head())
python# 自动筛选数值型列进行分析 target_cols = df.select_dtypes(include=[np.number]).columns.tolist() outlier_summary = [] for col in target_cols: data = df[col].dropna() if data.empty: continue # 四分位距计算 (IQR) 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)] outlier_summary.append({ 'target_col': col, 'outlier_count': len(outliers), 'outlier_ratio': f"{(len(outliers)/len(data)*100):.2f}%", 'lower_limit': lower_bound, 'upper_limit': upper_bound, 'sample_values': outliers.values.tolist()[:5] # 保留前5个示例 }) outlier_df = pd.DataFrame(outlier_summary) print("\n=== 异常值统计汇总 ===") print(outlier_df.to_string(index=False))
python# 配置多子图布局 num_cols = len(target_cols) cols_per_row = 3 rows = (num_cols + cols_per_row - 1) // cols_per_row fig, axes = plt.subplots(rows, cols_per_row, figsize=(18, 5 * rows)) fig.suptitle('数据分布与异常值检测箱线图', fontsize=16, fontweight='bold') axes_flat = axes.flatten() # 遍历绘制每个维度的分布 for i, col in enumerate(target_cols): ax = axes_flat[i] # 绘制箱线图并美化 sns.boxplot(y=df[col].dropna(), ax=ax, color='skyblue', width=0.4, flierprops=dict(marker='o', markerfacecolor='red', markersize=5, alpha=0.5)) ax.set_title(f'列: {col}', fontsize=12) ax.grid(True, linestyle='--', alpha=0.6) # 嵌入实时统计标注 stats = df[col].describe() stats_text = f'均值: {stats["mean"]:.2f}\n中位数: {stats["50%"]:.2f}\n标准差: {stats["std"]:.2f}' ax.text(0.05, 0.95, stats_text, transform=ax.transAxes, fontsize=9, verticalalignment='top', bbox=dict(boxstyle='round', facecolor='white', alpha=0.8)) # 隐藏多余的子图 for j in range(i + 1, len(axes_flat)): axes_flat[j].axis('off') plt.tight_layout(rect=[0, 0.03, 1, 0.95]) output_path = 'outlier_analysis_report.png' plt.savefig(output_path, dpi=300, bbox_inches='tight') plt.show()
python# 分析分布形态以辅助清洗决策 print("=== 数据分布形态分析报告 ===") quality_analysis = [] for col in target_cols: data = df[col].dropna() skewness = data.skew() kurtosis = data.kurtosis() # 判定分布特征 skew_type = "右偏 (Positive)" if skewness > 0.5 else "左偏 (Negative)" if skewness < -0.5 else "对称" kurt_type = "尖峰 (Leptokurtic)" if kurtosis > 1 else "平峰 (Platykurtic)" if kurtosis < -1 else "正态趋向" quality_analysis.append({ '字段': col, '偏度': round(skewness, 3), '峰度': round(kurtosis, 3), '分布形态': skew_type, '峰度特征': kurt_type }) analysis_df = pd.DataFrame(quality_analysis) print(analysis_df.to_string(index=False)) # 导出分析结果 # analysis_df.to_csv('data_quality_report.csv', index=False)
pythondef handle_outliers(df, col, method='cap'): """ 异常值处理骨架函数 method: 'cap' (盖帽法), 'drop' (删除), 'none' (保留) """ data = df[col].copy() Q1 = data.quantile(0.25) Q3 = data.quantile(0.75) IQR = Q3 - Q1 lower = Q1 - 1.5 * IQR upper = Q3 + 1.5 * IQR if method == 'cap': df[col] = df[col].clip(lower=lower, upper=upper) elif method == 'drop': df = df[(df[col] >= lower) & (df[col] <= upper)] return df # 示例:对特定列应用盖帽法处理 # df = handle_outliers(df, 'target_col', method='cap')
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-09 | fail→pass | 14,176 | 11,551 | -19% | 1 | 1 | 0% | 2,256 | 3,878 | +72% | 0 | 0 | — |
case-01 | fail→fail | 19,175 | 20,677 | +8% | 1 | 1 | 0% | 4,142 | 4,956 | +20% | 0 | 0 | — |
case-02 | fail→fail | 21,414 | 20,146 | -6% | 1 | 1 | 0% | 4,624 | 5,111 | +11% | 0 | 0 | — |
case-03 | fail→fail | 26,716 | 19,930 | -25% | 1 | 1 | 0% | 6,214 | 6,028 | -3% | 0 | 0 | — |
case-04 | pass→pass | 12,032 | 8,555 | -29% | 1 | 1 | 0% | 2,056 | 3,397 | +65% | 0 | 0 | — |
case-05 | pass→pass | 13,891 | 9,534 | -31% | 1 | 1 | 0% | 2,224 | 2,894 | +30% | 0 | 0 | — |
case-06 | pass→pass | 11,690 | 12,152 | +4% | 1 | 1 | 0% | 2,218 | 3,937 | +78% | 0 | 0 | — |
case-07 | pass→pass | 8,339 | 6,671 | -20% | 1 | 1 | 0% | 1,418 | 2,845 | +101% | 0 | 0 | — |
case-08 | pass→pass | 9,236 | 9,579 | +4% | 1 | 1 | 0% | 1,937 | 3,593 | +85% | 0 | 0 | — |
case-10 | pass→pass | 18,133 | 14,883 | -18% | 1 | 1 | 0% | 3,017 | 4,618 | +53% | 0 | 0 | — |
case-11 | pass→pass | 6,445 | 4,923 | -24% | 1 | 1 | 0% | 1,415 | 2,623 | +85% | 0 | 0 | — |
case-12 | pass→pass | 10,065 | 7,317 | -27% | 1 | 1 | 0% | 1,533 | 2,628 | +71% | 0 | 0 | — |
case-13 | fail→fail | 12,312 | 9,715 | -21% | 1 | 1 | 0% | 1,572 | 3,483 | +122% | 0 | 0 | — |
case-19 | pass→pass | 9,466 | 8,032 | -15% | 1 | 1 | 0% | 2,093 | 3,303 | +58% | 0 | 0 | — |
case-14 | fail→pass | 7,979 | 8,132 | +2% | 1 | 1 | 0% | 1,527 | 3,211 | +110% | 0 | 0 | — |
case-15 | fail→pass | 5,520 | 2,032 | -63% | 1 | 1 | 0% | 971 | 1,943 | +100% | 0 | 0 | — |
case-16 | fail→pass | 11,902 | 2,516 | -79% | 1 | 1 | 0% | 2,387 | 2,152 | -10% | 0 | 0 | — |
case-17 | fail→pass | 11,419 | 7,478 | -35% | 1 | 1 | 0% | 1,915 | 2,961 | +55% | 0 | 0 | — |
case-18 | pass→pass | 7,119 | 4,696 | -34% | 1 | 1 | 0% | 1,323 | 2,383 | +80% | 0 | 0 | — |
case-20 | pass→pass | 7,140 | 7,016 | -2% | 1 | 1 | 0% | 1,465 | 2,923 | +100% | 0 | 0 | — |
case-21 | pass→pass | 12,319 | 17,609 | +43% | 1 | 1 | 0% | 2,550 | 4,477 | +76% | 0 | 0 | — |
case-22 | pass→pass | 10,377 | 10,229 | -1% | 1 | 1 | 0% | 2,017 | 3,467 | +72% | 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 +23 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.