PineForge HPO 1.11.0
Native hyperparameter optimization for PineForge strategies
Loading...
Searching...
No Matches
pineforge_hpo.pareto Namespace Reference

Classes

class  ParetoError
 

Functions

dict pareto_front (Any source, Any axes, *bool with_domination_counts=False, int|None max_work=None)
 

Variables

str CONTRACT = "pineforge-hpo-pareto-front/v1"
 
str ALGORITHM = "exact_all_pairs_v1"
 
tuple DIRECTIONS = ("maximize", "minimize")
 
tuple CODES
 
tuple INTERPRETATION
 

Detailed Description

Post hoc Pareto front over the metrics recorded per trial.

``pareto_front`` takes the finished rows of one study (a complete result, a rows JSONL
file or a list of rows, read by the shared reader ``_rows``) and two or more axes, each
a recorded metric name with a caller-supplied direction, and returns the rows that no
other eligible row dominates. Nothing here runs a trial, writes a file, keeps state or
touches a native result: the only side effect is reading the one file named. There is
no Pareto sampler, no vector objective, no rank, hypervolume or crowding.

Contract ``pineforge-hpo-pareto-front/v1``, algorithm ``exact_all_pairs_v1``:

* Only rows with status ``ok`` compete. Every other status is excluded with the reason
  ``status_<status>``. An ``ok`` row whose ``metrics`` object, or an axis key in it, is
  absent is excluded as ``metric_not_recorded``; one whose axis value is ``null`` as
  ``metric_unavailable`` (the first reason that applies, in that order).
* An axis value of an ``ok`` row must be a finite number or ``null`` (a bool, string,
  array, object, non-finite number or overflowing integer refuses the call). A
  non-finite number in an axis cell of any row refuses too, as the ``NaN`` token does
  when the same data is read from a file.
* Row ``a`` dominates row ``b`` when ``a`` is no worse on every axis (in that axis's
  direction) and strictly better on at least one. Values are compared as exact binary64
  numbers, ``-0.0`` equals ``+0.0``, and equal vectors never dominate each other: both
  stay on the front. Every pair of eligible rows is compared in both directions.
* The result is ordered by ascending trial id and does not depend on the order of the
  rows or of the axes. ``input_sha256`` is the SHA-256 of the sorted per-row SHA-256
  digests (raw bytes) of the compact, key-sorted, ASCII JSON of
  ``[trial_id, status, {axis name: number as binary64, or null when absent or null}]``
  for every row read; the digest does not include the directions.
* ``interpretation`` is the fixed text of ``INTERPRETATION``: what the front is not.
* The admission figure is rows read + N(N-1)/2 for N eligible rows. The call is
  refused as ``pareto_resource_exceeded`` only against a ``max_work`` the caller gave.

A refusal is raised as ``ParetoError``; ``ParetoError.document()`` renders it as the
refused result document (no front). The checks run in this order, so the first defect
decides the code: axes and options (``pareto_parameter_missing`` before
``pareto_parameter_invalid``); the source (``pareto_input_invalid``,
``pareto_rows_incomplete``); the context of the rows (``pareto_context_mismatch``); the
axis names (``pareto_axis_unknown``, checked only when at least one row was read); the
axis values (``pareto_input_invalid``); ``pareto_no_eligible_rows``; the admission
figure (``pareto_resource_exceeded``).

Function Documentation

◆ pareto_front()

dict pineforge_hpo.pareto.pareto_front ( Any  source,
Any  axes,
*bool   with_domination_counts = False,
int | None   max_work = None 
)
Return the Pareto front of the eligible rows of ``source`` over ``axes``.

``source`` is whatever ``_rows.read_source`` takes: a path to a result JSON or a
rows JSONL, a parsed result dict or a parsed list of rows. ``axes`` is a list of at
least two ``{"name": <metric name as recorded>, "direction": "maximize" or
"minimize"}`` objects with distinct names; a direction has no default.
``with_domination_counts`` adds, for every eligible id, how many eligible rows
dominate it (0 exactly on the front). ``max_work`` is a positive integer bound on
the admission figure rows read + N(N-1)/2; None means no bound.

Returns the ``pineforge-hpo-pareto-front/v1`` document (see the module text).
Raises ``ParetoError`` for every refusal; nothing is returned for a refused call.

Definition at line 322 of file pareto.py.

Variable Documentation

◆ ALGORITHM

str pineforge_hpo.pareto.ALGORITHM = "exact_all_pairs_v1"

Definition at line 63 of file pareto.py.

◆ CODES

tuple pineforge_hpo.pareto.CODES
Initial value:
1= (
2 "pareto_input_invalid",
3 "pareto_rows_incomplete",
4 "pareto_context_mismatch",
5 "pareto_parameter_missing",
6 "pareto_parameter_invalid",
7 "pareto_axis_unknown",
8 "pareto_no_eligible_rows",
9 "pareto_resource_exceeded",
10)

Definition at line 65 of file pareto.py.

◆ CONTRACT

str pineforge_hpo.pareto.CONTRACT = "pineforge-hpo-pareto-front/v1"

Definition at line 62 of file pareto.py.

◆ DIRECTIONS

tuple pineforge_hpo.pareto.DIRECTIONS = ("maximize", "minimize")

Definition at line 64 of file pareto.py.

◆ INTERPRETATION

tuple pineforge_hpo.pareto.INTERPRETATION
Initial value:
1= (
2 "(a) No Pareto sampler and no multi-objective search (P-F8). "
3 "(b) The front is over the trials that a scalar-objective study chose to "
4 "evaluate: TPE learns from one value and abandons constraint-violating trials "
5 "(study-spec.md:765-767, 790-794), so the sampler never searched the other axes. "
6 "The front is the front of the evaluated rows, not the true front, and its extent "
7 "depends on the sampler, the seed and the budget. "
8 "(c) A row excluded for a missing value, or for violating a constraint, may belong "
9 "to the true front. "
10 "(d) In-sample: no holdout (study-spec.md:376-377). "
11 "(e) No claim of spread, diversity, optimality or hypervolume; equal vectors are "
12 "not merged. "
13 "(f) Directions are the caller's; the module does not know a metric's sign "
14 "convention (P-F5). "
15 "(g) Rows of one lineage may come from different scoring contexts that the space "
16 "hash cannot detect (P-F13); the clause 2(e) checks are necessary, not sufficient."
17)

Definition at line 76 of file pareto.py.