Metric format

HyperOptimizer collects metrics from stdout lines that match the hpo.metrics.<key>=<json> format.

Format

hpo.metrics.<key>=<json>
  • Name
    hpo.metrics.
    Type
    prefix
    Description

    Required prefix. The collector ignores lines without it.

  • Name
    <key>
    Type
    string
    Description

    Metric name, such as sharpe, loss, or max_drawdown.

  • Name
    <json>
    Type
    JSON value
    Description

    JSON-serializable value produced by your program.

Valid values

Use JSON numbers, strings, booleans, arrays, or objects. Numeric objective metrics are the most useful for optimization.

hpo.metrics.loss=0.182
hpo.metrics.accuracy=0.94
hpo.metrics.valid=true
hpo.metrics.notes="completed"

Examples

import json

def emit_metric(key, value):
    print(f"hpo.metrics.{key}={json.dumps(value, default=str)}")

emit_metric("objective", 0.84)
emit_metric("duration_seconds", 42.1)
stdoutcollected
hpo.metrics.objective=0.84
hpo.metrics.duration_seconds=42.1
hpo.metrics.status="completed"

Common mistakes

Missing prefix

metrics.loss=0.2 will not be collected. Use hpo.metrics.loss=0.2.

Invalid JSON

hpo.metrics.loss=nan is not valid JSON. Convert special values before printing.

Wrong objective name

If the dashboard expects sharpe, printing sharp will not satisfy the objective.

Only writing files

Writing metrics to a JSON file is not enough for collection. Print them to stdout.

Was this page helpful?