agentsclimarketplace

Run1 pareto frontier computation

Skill cxcscmu/SkillLearnBench/skills/b3-teacher-feedback-claude-sonnet-4-6/dbscan-parameter-tuning/run1_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.From its SKILL.md

Install
npx -y skills add cxcscmu/SkillLearnBench --skill run1_pareto-frontier-computation

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

SKILL.md

4.0 KB, 994 tokens by cl100k_base, as published. Nobody here has run it

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.F1 AND A.delta <= B.delta
  • AND at least one is strict: A.F1 > B.F1 OR A.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)

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.