pareto-frontier-computation
How to compute the Pareto frontier from a set of (F1, delta) optimization results where F1 is maximized and delta is minimized. Includes filtering, dominance checking, and CSV output formatting.
- License 许可
- MIT
- 最近更新
- 2026-10-02
- Stars
- ★ 93
- Forks
- 8
01 前言 Front Matter
- name
- pareto-frontier-computation
- description
- How to compute the Pareto frontier from a set of (F1, delta) optimization results where F1 is maximized and delta is minimized. Includes filtering, dominance checking, and CSV output formatting.
03 SKILL.md 正文
Pareto Frontier Computation
Overview
Given a set of solutions with multiple objectives, the Pareto frontier contains all non-dominated solutions: a solution is dominated if another solution is at least as good on all objectives and strictly better on at least one.
For this task:
- Maximize F1 (higher is better)
- Minimize delta (lower is better)
Dominance Definition
Solution A dominates solution B if:
A.F1 >= B.F1ANDA.delta <= B.delta- AND at least one is strict:
A.F1 > B.F1ORA.delta < B.delta
Implementation
import numpy as np
import pandas as pd
def compute_pareto_frontier(df):
"""
df: DataFrame with columns [F1, delta, min_samples, epsilon, shape_weight]
Returns: DataFrame of Pareto-optimal rows (non-dominated solutions).
"""
# Work with numpy for speed
f1 = df['F1'].values
delta = df['delta'].values
n = len(df)
is_pareto = np.ones(n, dtype=bool)
for i in range(n):
if not is_pareto[i]:
continue
# Check if solution i is dominated by any other solution j
for j in range(n):
if i == j or not is_pareto[j]:
continue
# j dominates i if j is at least as good on all objectives
# and strictly better on at least one
j_dominates_i = (
f1[j] >= f1[i] and delta[j] <= delta[i] and
(f1[j] > f1[i] or delta[j] < delta[i])
)
if j_dominates_i:
is_pareto[i] = False
break
return df[is_pareto].copy()
def compute_pareto_vectorized(df):
"""
Vectorized Pareto computation — faster for large result sets.
"""
f1 = df['F1'].values
delta = df['delta'].values
n = len(df)
is_pareto = np.ones(n, dtype=bool)
for i in range(n):
if not is_pareto[i]:
continue
# All other points that are at least as good on both objectives
# and strictly better on at least one
dominated_by = (
(f1 >= f1[i]) & (delta <= delta[i]) &
((f1 > f1[i]) | (delta < delta[i]))
)
dominated_by[i] = False # Don't compare to self
if dominated_by.any():
is_pareto[i] = False
return df[is_pareto].copy()
Filtering and Output
def filter_and_save_pareto(results, output_path):
"""
results: list of dicts with keys [F1, delta, min_samples, epsilon, shape_weight]
"""
df = pd.DataFrame(results, columns=['F1', 'delta', 'min_samples', 'epsilon', 'shape_weight'])
# Filter: only keep results with average F1 > 0.5
df = df[df['F1'] > 0.5].copy()
if df.empty:
print("No solutions with F1 > 0.5 found.")
df.to_csv(output_path, index=False)
return df
# Compute Pareto frontier
pareto = compute_pareto_vectorized(df)
# Round outputs
pareto['F1'] = pareto['F1'].round(5)
pareto['delta'] = pareto['delta'].round(5)
pareto['shape_weight'] = pareto['shape_weight'].round(1)
pareto['min_samples'] = pareto['min_samples'].astype(int)
pareto['epsilon'] = pareto['epsilon'].astype(int)
# Sort for readable output (optional but conventional)
pareto = pareto.sort_values(['F1', 'delta'], ascending=[False, True])
pareto[['F1', 'delta', 'min_samples', 'epsilon', 'shape_weight']].to_csv(
output_path, index=False
)
return pareto
Notes
- After rounding, multiple parameter combinations may map to identical (F1, delta) points — all should be retained if they were non-dominated before rounding
- With only two objectives, the Pareto frontier, when sorted by F1 descending, will have delta strictly increasing (otherwise one would dominate another)
04 同仓库更多 Skills
object_counter
Count occurrences of an object in the image using computer vision algorithm.
travel-planning-workflow
Invoke this skill when performing travel planning. It defines a structured workflow for generating itineraries. Following this workflow is essential to ensure the final plan satisfies user requirements.
bundled-dataset-search-tool
invoke this skill when you need to perform database search for travel planning. This skill provides some useful pre-packaged tools to look up accommodations, attractions, cities, driving distance, flights, and restaurants from the bundled dataset.
glm-output
Output-processing guidance for GLM tasks. Especially useful after glm-basics and glm-calibration when you need verifier-matching metrics from output.nc and a final /root/metrics.json.
glm-calibration
Calibration guidance for GLM tasks. Often most effective after glm-basics has clarified the setup; glm-output is the companion skill for exact final metric computation.
glm-basics
A good starting point for GLM calibration tasks. Use to inspect glm3.nml, confirm how GLM runs, and identify the relevant files before moving on to calibration and output evaluation.