trailing_skill

trailing_skill(
    subjects,
    *,
    order_column,
    forecast_column='forecast',
    consensus_column=CONSENSUS_SOURCE,
    actual_column='actual',
    entity_column=ENTITY_COLUMN,
    error_clip=defaults.TRAILING_ERROR_CLIP,
)

Attach each row’s trailing skill, computed from its entity’s prior rows.

Skill is the log ratio of the consensus’s mean absolute percentage error to the forecaster’s, over prior reports; positive means the forecaster has been closer. The hit rate is the share of prior reports where the forecaster’s side of the consensus matched the actual’s.

Parameters

Name Type Description Default
subjects pd.DataFrame One row per entity and report, with forecast, consensus and actual values and an ordering column. required
order_column str Column ordering each entity’s reports in time. required
forecast_column str Column holding the forecast. 'forecast'
consensus_column str Column holding the consensus. CONSENSUS_SOURCE
actual_column str Column holding the realised value. 'actual'
entity_column str Column identifying the entity. ENTITY_COLUMN
error_clip float Upper bound on each absolute percentage error. defaults.TRAILING_ERROR_CLIP

Returns

Name Type Description
pd.DataFrame A copy of subjects, in its order, with the prior event count, both prior mean errors, the relative skill and the prior hit rate.

Raises

Name Type Description
PanelError A required column is absent.