hybrid_aif.reference.raif.metrics#
R-AIF’s three metrics: ACR, SR and R-S, folded from recorded training episodes.
They are online training statistics over the last WINDOW episodes; nothing here
steps an environment. ACR is the mean raw episode score, SR the fraction of episodes that
reached the goal, and R-S (lower is better) how far the rolling mean of C sits below the
best episode’s. R-S depends on the task’s per-step offset (MC_OFFSET).
Design: docs/design/amortization-p0-addendum.md §6.
Module Attributes
|
|
Their window: "the last 100 recorded agent training episodes" (paper §4). |
Functions
|
Typed version of namedtuple. |
|
Average cumulative reward: the mean episode score, raw and unoffset. |
|
Per-episode summed reward, with |
|
The three metrics over the last |
|
|
|
R-S over per-episode |
|
Success rate: the fraction of episodes that reached the goal at least once. |
|
R-S's |
Classes
|
- hybrid_aif.reference.raif.metrics.MC_OFFSET = 1.1#
r_reward_offsetper task (configs.yaml:116,126,137). R-S only.
- hybrid_aif.reference.raif.metrics.WINDOW = 100#
Their window: “the last 100 recorded agent training episodes” (paper §4).
- class hybrid_aif.reference.raif.metrics.Metrics[source]#
Bases:
NamedTuple(acr, sr, rs)over one window, plusn, the number of episodes in it.A window shorter than
WINDOWis a different statistic from a full one.- static __new__(_cls, acr, sr, rs, n)#
Create new instance of Metrics(acr, sr, rs, n)
- hybrid_aif.reference.raif.metrics.acr(returns)[source]#
Average cumulative reward: the mean episode score, raw and unoffset.
- hybrid_aif.reference.raif.metrics.sr(successes)[source]#
Success rate: the fraction of episodes that reached the goal at least once.
- hybrid_aif.reference.raif.metrics.relative_stability(returns, offset=1.1, window=100)[source]#
R-S over per-episode
C: how far the rolling mean sits below the best. Lower is better.R-S = mean_k |rolling_mean_window(C)_k − max(C)| / |max(C)|over the lastwindowrolling means, withmax(C)over the whole history. With fewer thanwindowepisodes the rolling mean is taken over what there is, and the result is not comparable to a full run’s. RaisesValueErroron no episodes or onmax(C) == 0.Design:
docs/experiments/raif-mountain-car/execution-ledger-acting.mdD9.
- hybrid_aif.reference.raif.metrics.episode_returns(rewards, offset=0.0)[source]#
Per-episode summed reward, with
offsetadded per step.rewardsis(episodes, steps)or a ragged sequence of reward columns. Atoffset=0this is the score ACR averages. R-S’sCisstability_c(), not this.
- hybrid_aif.reference.raif.metrics.stability_c(rewards, offset=1.1)[source]#
R-S’s
Cfor one episode:Σ_{t<T} (reward[t] + offset)over itsT+1rows.The closing
is_lastrow contributes nothing and the reset row contributes oneoffset, as theirMeasureRStabilityaccumulates.rewardsis one episode’s(T+1,)reward column in row order.Design:
docs/experiments/raif-mountain-car/execution-ledger-acting.mdD9.
- hybrid_aif.reference.raif.metrics.evaluate(rewards, successes, *, offset=1.1, window=100)[source]#
The three metrics over the last
windowepisodes of a training run.rewardsis(episodes, steps)or a sequence of per-episode reward columns, one whole unpadded episode each;successes(episodes,)is each episode’shas_succeeded[-1]. ACR and SR are over the window. R-S is over the window’s rolling means against the best episode in the whole history.