leaderboard
agentic_ml.core.leaderboard
¶
The CSV leaderboard: the persistent, human-readable memory of every trial's metrics.
Columns are, in order: ID, Status, one column per requested metric, and runtime.
Failed trials store NaN for every metric and for runtime.
Leaderboard
¶
Leaderboard(path: str | Path, metric_names: list[str])
Read/append access to leaderboard.csv for a fixed set of metric columns.
The leaderboard is the durable, human-readable memory of a research run: every call to
:func:~agentic_ml.core.engine.create_trial_action appends one row here, and the agent
reads it back (via the read_leaderboard / read_leaderboard_row tools) to decide
what to try next. It is a thin wrapper around a CSV file rather than an in-memory
structure, so it survives process restarts and can be inspected with any spreadsheet tool.
Attributes:
| Name | Type | Description |
|---|---|---|
path |
Filesystem path to |
|
metric_names |
The metric columns tracked for this run, in the order given at construction (fixed for the run's lifetime). |
|
columns |
Full column order written to the CSV: |
Store the leaderboard location and the fixed set of metric columns to track.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Where to read/write |
required |
metric_names
|
list[str]
|
Metric columns tracked for this run, in the order used for every row; must match the run's configured metrics. |
required |
Source code in src/agentic_ml/core/leaderboard.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |
ensure
¶
ensure() -> None
Create the CSV with its header if it does not exist yet; a no-op otherwise.
Source code in src/agentic_ml/core/leaderboard.py
58 59 60 61 | |
append
¶
append(
trial_id: str,
status: str,
metrics: dict[str, float | None] | None,
runtime: float | None,
description: str = "",
) -> None
Append a single trial result as a new row.
Missing or None metric values (e.g. for a failed trial) are stored as NaN so
the column stays numeric and easy to sort/aggregate.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trial_id
|
str
|
The trial's id (matches its folder name under the workspace). |
required |
status
|
str
|
|
required |
metrics
|
dict[str, float | None] | None
|
Metric name to value mapping; entries missing from |
required |
runtime
|
float | None
|
Wall-clock evaluation time in seconds, or |
required |
description
|
str
|
Free-text note about the trial; the caller is expected to have already sanitized/truncated it. |
''
|
Source code in src/agentic_ml/core/leaderboard.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | |
read
¶
read() -> DataFrame
Return the whole leaderboard as a DataFrame, creating an empty one if needed.
Source code in src/agentic_ml/core/leaderboard.py
101 102 103 104 | |
best
¶
best(metric: str, maximize: bool) -> str | None
Return the ID of the best successful trial by metric, or None.
Only rows with Status == "ok" and a non-NaN value for metric are
considered.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metric
|
str
|
Column name to rank by (must be one of |
required |
maximize
|
bool
|
Whether a larger value of |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
The winning trial's |
Source code in src/agentic_ml/core/leaderboard.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | |