Skip to content

latent.stats.pareto

Multi-objective Pareto frontier analysis and visualization.

Functions

pareto_frontier

pareto_frontier(results: dict[str, dict[str, float]], lower_is_better: set[str] | None = None) -> dict[str, Any]

Identify Pareto-optimal configurations from multi-objective results.

A configuration is Pareto-optimal if no other configuration is strictly better on all metrics simultaneously.

Args: results: Dict mapping configuration name to {metric_name: value}. Example: {"gpt-4o": {"accuracy": 0.89, "latency": 2.1, "cost": 0.032}} lower_is_better: Set of metric names where lower values are better (e.g. {"latency", "cost"}). All other metrics are treated as higher-is-better.

Returns: Dict with keys: - "pareto_optimal": list of config names on the Pareto frontier - "dominated_by": dict mapping dominated configs to list of configs that dominate them - "table": list of dicts with config name, metric values, and is_pareto flag

plot_pareto

plot_pareto(results: dict[str, dict[str, float]], x_metric: str, y_metric: str, lower_is_better: set[str] | None = None, title: str | None = None, save_path: str | None = None) -> Any

Create a scatter plot with Pareto frontier highlighted.

Args: results: Same format as pareto_frontier(). x_metric: Metric name for x-axis. y_metric: Metric name for y-axis. lower_is_better: Set of metric names where lower is better. title: Plot title. Defaults to "Pareto Frontier: {x} vs {y}". save_path: Optional file path to save the plot (PNG/PDF).

Returns: matplotlib Figure object.