Install any skill in seconds. Free to start, no credit card required.
Get Started Free →提取指定类别列并统计各类别数量与占比,生成高分辨率的柱状图、饼图等组合可视化报告,适用于分类数据的分布情况分析。
.claude/skills/opensensenova-category-statistics/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 8% | 0% |
| case-04 | ✗→✓ | ▲ Improved | 9% | 0% |
| case-14 | ✗→✓ | ▲ Improved | 40% | 0% |
| case-08 | ✓→✓ | = Same ✓ | 90% | 0% |
| case-03 | ✓→✓ | = Same ✓ | 31% | 0% |
Step1 提取目标类别数据,清洗无效标签,并统计各类别数量与占比。
pythonimport pandas as pd def calculate_distribution(data, target_col='类别'): # 检查目标列是否存在 if target_col not in data.columns: raise ValueError(f'未找到指定的类别字段: {target_col}') # 提取数据,清洗无效标签(如'--'、'代码'等占位符) category_data = data[target_col].dropna().replace(['--', '代码'], pd.NA).dropna() # 统计各类别数量并计算占比 counts = category_data.value_counts() proportions = (counts / counts.sum()) * 100 # 实用技巧:生成包含总计行的统计表 # summary = counts.copy() # summary.loc['总计'] = counts.sum() return counts, proportions
Step2 生成基础可视化(双轴图:柱状图+占比曲线),并保存为高分辨率图片。
pythonimport matplotlib.pyplot as plt def generate_and_save_basic_chart(counts, proportions, title='各类别数量分布', output_path='category_distribution.png'): # 设置中文字体避免乱码 plt.rcParams['font.sans-serif'] = ['SimHei', 'WenQuanYi Zen Hei', 'Noto Sans CJK JP', 'DejaVu Sans'] plt.rcParams['axes.unicode_minus'] = False fig, ax1 = plt.subplots(figsize=(10, 6)) # 绘制柱状图 bars = ax1.bar(counts.index, counts.values, color='skyblue', edgecolor='black') for bar in bars: height = bar.get_height() ax1.text(bar.get_x() + bar.get_width()/2., height + 0.05, f'{height}', ha='center', va='bottom', fontsize=10) ax1.set_ylabel('数量', fontsize=12) ax1.set_title(title, fontsize=16, fontweight='bold', pad=20) # 创建第二个y轴显示占比曲线 ax2 = ax1.twinx() ax2.plot(counts.index, proportions.values, color='red', marker='o', linestyle='-', linewidth=2) ax2.set_ylabel('占比 (%)', color='red', fontsize=12) ax2.tick_params(axis='y', labelcolor='red') plt.xticks(rotation=45) plt.tight_layout() # 保存高分辨率图表并使用 plt.close() 防止内存泄漏 fig.savefig(output_path, dpi=300, bbox_inches='tight') plt.close(fig) return output_path
Step3 生成多图组合报告(饼图+柱状图,以及带分类映射的水平柱状图),用于多维度展示。
pythonimport matplotlib.pyplot as plt from matplotlib.patches import Patch def generate_comprehensive_report(counts, proportions, output_dir='./'): plt.rcParams['font.sans-serif'] = ['SimHei', 'WenQuanYi Zen Hei', 'Noto Sans CJK JP', 'DejaVu Sans'] plt.rcParams['axes.unicode_minus'] = False # --- 1. 饼图与柱状图组合 --- fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(15, 6)) # 饼图 colors = ['#ff9999', '#66b3ff', '#99ff99', '#ffcc99'] explode = [0.05] * len(counts) if len(counts) > 0 else None wedges, texts, autotexts = ax1.pie(counts.values, labels=counts.index, autopct='%1.1f%%', colors=colors[:len(counts)], explode=explode, shadow=True, startangle=90) ax1.set_title('各类别比例分布', fontsize=14, fontweight='bold') for autotext in autotexts: autotext.set_color('white') autotext.set_fontweight('bold') # 柱状图 bars = ax2.bar(range(len(counts)), counts.values, color=colors[:len(counts)], alpha=0.8, edgecolor='black') ax2.set_title('各类别数量', fontsize=14, fontweight='bold') ax2.set_xticks(range(len(counts))) ax2.set_xticklabels(counts.index, rotation=45, ha='right') for i, bar in enumerate(bars): height = bar.get_height() ax2.text(bar.get_x() + bar.get_width()/2., height + 0.5, f'{int(height)}\n({proportions.iloc[i]:.1f}%)', ha='center', va='bottom', fontweight='bold') plt.tight_layout() pie_bar_path = f'{output_dir}category_pie_bar.png' plt.savefig(pie_bar_path, dpi=300, bbox_inches='tight') plt.close(fig) # --- 2. 水平柱状图 (带分类映射函数骨架与颜色区分) --- fig_h, ax_h = plt.subplots(figsize=(12, 8)) positions = [f'类别{i+1}' for i in range(len(counts))] # 分类映射示例:根据类别名称包含的关键字动态分配颜色 bar_colors = ['#66b3ff' if '关键字A' in str(p) else '#ff9999' for p in counts.index] bars_h = ax_h.barh(positions, counts.values, color=bar_colors, alpha=0.8, edgecolor='black') ax_h.set_title('各类别分布详情', fontsize=16, fontweight='bold', pad=20) for i, (bar, label) in enumerate(zip(bars_h, counts.index)): width = bar.get_width() # 动态标签示例:提取特定属性 tag = '类型A' if '关键字A' in str(label) else '其他' ax_h.text(width + 0.3, bar.get_y() + bar.get_height()/2, f'{int(width)} ({tag})', ha='left', va='center', fontsize=10) # 自定义图例 legend_elements = [Patch(facecolor='#66b3ff', label='类型A组'), Patch(facecolor='#ff9999', label='其他组')] ax_h.legend(handles=legend_elements, loc='lower right') ax_h.grid(axis='x', alpha=0.3) plt.tight_layout() hbar_path = f'{output_dir}category_hbar.png' plt.savefig(hbar_path, dpi=300, bbox_inches='tight') plt.close(fig_h) return [pie_bar_path, hbar_path]
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→pass | 19,243 | 11,682 | -39% | 1 | 1 | 0% | 3,491 | 3,767 | +8% | 0 | 0 | — |
case-02 | fail→fail | 18,753 | 13,088 | -30% | 1 | 1 | 0% | 3,988 | 4,691 | +18% | 0 | 0 | — |
case-08 | pass→pass | 12,182 | 7,869 | -35% | 1 | 1 | 0% | 1,802 | 3,427 | +90% | 0 | 0 | — |
case-03 | pass→pass | 25,560 | 18,782 | -27% | 1 | 1 | 0% | 3,902 | 5,120 | +31% | 0 | 0 | — |
case-04 | fail→pass | 14,290 | 6,212 | -57% | 1 | 1 | 0% | 2,686 | 2,935 | +9% | 0 | 0 | — |
case-05 | fail→fail | 13,364 | 12,384 | -7% | 1 | 1 | 0% | 2,477 | 3,654 | +48% | 0 | 0 | — |
case-06 | pass→pass | 20,614 | 17,340 | -16% | 1 | 1 | 0% | 3,344 | 5,174 | +55% | 0 | 0 | — |
case-07 | pass→pass | 11,904 | 8,513 | -28% | 1 | 1 | 0% | 2,143 | 3,332 | +55% | 0 | 0 | — |
case-09 | pass→pass | 12,267 | 9,386 | -23% | 1 | 1 | 0% | 2,459 | 3,296 | +34% | 0 | 0 | — |
case-10 | pass→pass | 14,947 | 8,012 | -46% | 1 | 1 | 0% | 2,327 | 3,443 | +48% | 0 | 0 | — |
case-11 | pass→pass | 11,294 | 6,909 | -39% | 1 | 1 | 0% | 2,201 | 3,029 | +38% | 0 | 0 | — |
case-12 | fail→fail | 8,754 | 6,886 | -21% | 1 | 1 | 0% | 1,763 | 2,628 | +49% | 0 | 0 | — |
case-13 | pass→pass | 14,678 | 10,807 | -26% | 1 | 1 | 0% | 2,111 | 3,386 | +60% | 0 | 0 | — |
case-14 | fail→pass | 10,142 | 5,920 | -42% | 1 | 1 | 0% | 2,093 | 2,925 | +40% | 0 | 0 | — |
case-15 | fail→fail | 12,315 | 11,192 | -9% | 1 | 1 | 0% | 2,378 | 3,627 | +53% | 0 | 0 | — |
case-16 | pass→pass | 11,334 | 8,702 | -23% | 1 | 1 | 0% | 2,181 | 3,388 | +55% | 0 | 0 | — |
case-17 | pass→pass | 17,276 | 13,131 | -24% | 1 | 1 | 0% | 3,713 | 3,983 | +7% | 0 | 0 | — |
case-18 | fail→fail | 12,285 | 6,828 | -44% | 1 | 1 | 0% | 2,502 | 2,897 | +16% | 0 | 0 | — |
case-19 | pass→pass | 9,306 | 15,560 | +67% | 1 | 1 | 0% | 1,721 | 2,987 | +74% | 0 | 0 | — |
case-20 | pass→pass | 12,507 | 10,780 | -14% | 1 | 1 | 0% | 2,579 | 4,046 | +57% | 0 | 0 | — |
case-21 | pass→pass | 14,090 | 9,705 | -31% | 1 | 1 | 0% | 2,187 | 3,762 | +72% | 0 | 0 | — |
case-22 | pass→pass | 4,849 | 3,556 | -27% | 1 | 1 | 0% | 836 | 2,423 | +190% | 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.