dymad.training.helper

Functions

aggregate_cv_results(results)

The results are potentially from concurrent runs, and each is in the format of

bounded_nelder_mead_search_points(*, ...[, ...])

Evaluate points through a bounded Nelder-Mead search in a continuous box domain.

get_by_dotted_key(d, dotted_key)

Read nested dict/list paths for dotted keys such as 'a.b.c' or 'phases.0.n_epochs'.

iter_param_grid(param_grid)

param_grid: dict mapping dotted keys to iterables.

nelder_mead_like_search_indices(combos, *, ...)

Evaluate combo candidates through a discrete Nelder-Mead-like search path.

select_best_cv_result(cv_results, *[, goal, ...])

Return the selected best CV-result index using explicit selection rules.

set_by_dotted_key(d, dotted_key, value)

Set nested dict/list paths for dotted keys such as 'a.b.c' or 'phases.0.n_epochs'.

Classes

CVResult(params, fold_metrics[, ...])

class dymad.training.helper.CVResult(params, fold_metrics, mean_metric=0.0, std_metric=0.0, checkpoint_paths=<factory>)

Bases: object

checkpoint_paths: list[str]
fold_metrics: list[float]
mean_metric: float = 0.0
params: dict[str, Any]
std_metric: float = 0.0
dymad.training.helper.aggregate_cv_results(results)

The results are potentially from concurrent runs, and each is in the format of

{‘combo_idx’, ‘fold_idx’, ‘combo’, ‘metric_value’, ‘model_prefix’}

This function aggregates them into CVResult objects by collecting fold results for each combo_idx.

dymad.training.helper.bounded_nelder_mead_search_points(*, lower_bounds, upper_bounds, evaluate_point, goal='minimize', max_iterations=None, reflection=1.0, expansion=2.0, contraction=0.5, shrink=0.5)

Evaluate points through a bounded Nelder-Mead search in a continuous box domain.

Returns the ordered list of unique denormalized points that were evaluated.

Return type:

list[ndarray]

dymad.training.helper.get_by_dotted_key(d, dotted_key)

Read nested dict/list paths for dotted keys such as ‘a.b.c’ or ‘phases.0.n_epochs’.

Return type:

Any

dymad.training.helper.iter_param_grid(param_grid)

param_grid: dict mapping dotted keys to iterables. Yields dicts mapping dotted keys -> single value.

dymad.training.helper.nelder_mead_like_search_indices(combos, *, evaluate_index, goal='minimize', max_iterations=None, reflection=1.0, expansion=2.0, contraction=0.5, shrink=0.5)

Evaluate combo candidates through a discrete Nelder-Mead-like search path.

Returns the ordered list of evaluated combo indices. If candidate values are non-numeric (or key structure is inconsistent), the function deterministically falls back to evaluating the full grid order.

Return type:

list[int]

dymad.training.helper.select_best_cv_result(cv_results, *, goal='minimize', tie_breakers=('std_metric', 'combo_index'), combo_indices=None)

Return the selected best CV-result index using explicit selection rules.

Return type:

int

Supported goals:
  • minimize: lower mean metric is better

  • maximize: higher mean metric is better

Supported tie breakers (applied in order):
  • std_metric: lower std is better

  • param_l1: lower numeric L1 score of tuned params is better

  • combo_index: lower candidate index is better. Uses combo_indices when provided; otherwise uses the cv_results list position.

dymad.training.helper.set_by_dotted_key(d, dotted_key, value)

Set nested dict/list paths for dotted keys such as ‘a.b.c’ or ‘phases.0.n_epochs’. Creates intermediate containers as needed.