用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/cxcscmu/SkillLearnBench --skill run2-pareto-frontier命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
| name | run2_pareto_frontier |
| description | Find Pareto-optimal solutions balancing multiple conflicting objectives with rigorous verification |
Objectives:
These objectives are conflicting: improving one typically worsens the other.
Solution A dominates B if:
A solution is Pareto-optimal (non-dominated) if no other solution dominates it.
import numpy as np
import pandas as pd
def is_dominated(i, F1, delta):
"""
Check if point i is dominated by any other point.
"""
f1_i, delta_i = F1[i], delta[i]
for j in range(len(F1)):
if i == j:
continue
f1_j, delta_j = F1[j], delta[j]
# Check if j dominates i
if (f1_j >= f1_i and delta_j <= delta_i and
(f1_j > f1_i or delta_j < delta_i)):
return True # j dominates i
return False
def find_pareto_frontier(results_df):
"""
Identify all Pareto-optimal solutions.
Parameters:
- results_df: DataFrame with columns ['F1', 'delta', 'min_samples', 'epsilon', 'shape_weight']
Returns:
- pareto_df: Subset of results_df containing only Pareto-optimal points
"""
F1 = results_df['F1'].values
delta = results_df['delta'].values
n = len(results_df)
pareto_mask = np.ones(n, dtype=bool)
for i in range(n):
if is_dominated(i, F1, delta):
pareto_mask[i] = False
return results_df[pareto_mask].copy()
Before finding the Pareto frontier, filter to meaningful solutions:
# Filter by F1 > 0.5
filtered_df = results_df[results_df['F1'] > 0.5].copy()
# Then find Pareto frontier on filtered set
pareto_df = find_pareto_frontier(filtered_df)
Rationale:
def format_pareto_output(pareto_df):
"""
Format Pareto frontier for CSV output.
"""
output_df = pareto_df[['F1', 'delta', 'min_samples', 'epsilon', 'shape_weight']].copy()
# Round according to specifications
output_df['F1'] = output_df['F1'].round(5)
output_df['delta'] = output_df['delta'].round(5)
output_df['shape_weight'] = output_df['shape_weight'].round(1)
# Integer columns stay as integers
output_df['min_samples'] = output_df['min_samples'].astype(int)
output_df['epsilon'] = output_df['epsilon'].astype(int)
# Sort by delta for readability (ascending)
output_df = output_df.sort_values('delta').reset_index(drop=True)
return output_df
# Example
pareto_df = find_pareto_frontier(results_df[results_df['F1'] > 0.5])
output_df = format_pareto_output(pareto_df)
output_df.to_csv('pareto_frontier.csv', index=False)
Every point on the frontier is Pareto-optimal.
Different stakeholders can choose based on preferences:
def verify_pareto_frontier(pareto_df, all_results_df):
"""
Sanity checks for Pareto frontier.
"""
F1_pareto = pareto_df['F1'].values
delta_pareto = pareto_df['delta'].values
F1_all = all_results_df['F1'].values
delta_all = all_results_df['delta'].values
# Check 1: Max F1 is on frontier
max_f1_idx = F1_all.argmax()
assert max_f1_idx in pareto_df.index, "Max F1 must be on frontier"
# Check 2: Min delta is on frontier (of F1 > 0.5)
min_delta_idx = delta_all.argmin()
if F1_all[min_delta_idx] > 0.5:
assert min_delta_idx in pareto_df.index, "Min delta must be on frontier"
# Check 3: No point outside frontier dominates any frontier point
for i in pareto_df.index:
f1_i, delta_i = F1_all[i], delta_all[i]
for j in range(len(all_results_df)):
if j == i or j not in pareto_df.index:
continue
f1_j, delta_j = F1_all[j], delta_all[j]
# Non-frontier point j should not dominate frontier point i
assert not (f1_j > f1_i and delta_j < delta_i), \
f"Non-frontier point {j} dominates frontier point {i}"
print("✓ Pareto frontier verification passed")
filtered_df = results_df[results_df['F1'] > 0.5]
if len(filtered_df) == 0:
print("No solutions with F1 > 0.5")
pareto_df = pd.DataFrame(columns=['F1', 'delta', 'min_samples', 'epsilon', 'shape_weight'])
else:
pareto_df = find_pareto_frontier(filtered_df)
def pareto_summary(pareto_df):
"""Print summary of Pareto frontier."""
print(f"Pareto frontier size: {len(pareto_df)}")
print(f"F1 range: [{pareto_df['F1'].min():.5f}, {pareto_df['F1'].max():.5f}]")
print(f"Delta range: [{pareto_df['delta'].min():.5f}, {pareto_df['delta'].max():.5f}]")
print(f"Shape weight distribution:")
print(pareto_df['shape_weight'].value_counts().sort_index())
基于 SOC 职业分类