Objective๏ƒ

Objective: the metric a problem ranks on, with a direction.

Metrics are pure functions (see emflow.problems.metrics); an Objective is the one a leaderboard sorts by โ€” it adds direction (lower_is_better) and comparison helpers. This is what rebase-hillclimbโ€™s val_score: line ultimately reports.

class emflow.problems.objective.Objective(metric: 'Metric', lower_is_better: 'bool' = True)[source]๏ƒ

Bases: object

metric: Metric๏ƒ
lower_is_better: bool = True๏ƒ
property name: str๏ƒ
calculate(y_true, y_pred) float[source]๏ƒ
elementwise(y_true, y_pred)[source]๏ƒ
is_better(a: float, b: float) bool[source]๏ƒ

True if score a beats score b.

class emflow.problems.objective.Metric[source]๏ƒ

Bases: ABC

Base class for metrics. Stateless; safe to share across problems.

aggregate: str = 'mean'๏ƒ

How per-origin scores combine into an overall score: โ€œmeanโ€ (pooled by scored timestamps โ€” error metrics) or โ€œsumโ€ (revenue-type metrics).

property name: str๏ƒ
abstract elementwise(y_true, y_pred)[source]๏ƒ

Per-timestamp scores (NaN where either side is missing).

calculate(y_true, y_pred) float[source]๏ƒ
class emflow.problems.objective.MeanAbsoluteError[source]๏ƒ

Bases: Metric

elementwise(y_true, y_pred)[source]๏ƒ

Per-timestamp scores (NaN where either side is missing).

aggregate: str = 'mean'๏ƒ

How per-origin scores combine into an overall score: โ€œmeanโ€ (pooled by scored timestamps โ€” error metrics) or โ€œsumโ€ (revenue-type metrics).

calculate(y_true, y_pred) float๏ƒ
property name: str๏ƒ
class emflow.problems.objective.MeanSquaredError(squared: bool = True)[source]๏ƒ

Bases: Metric

property name๏ƒ
elementwise(y_true, y_pred)[source]๏ƒ

Per-timestamp scores (NaN where either side is missing).

calculate(y_true, y_pred) float[source]๏ƒ
aggregate: str = 'mean'๏ƒ

How per-origin scores combine into an overall score: โ€œmeanโ€ (pooled by scored timestamps โ€” error metrics) or โ€œsumโ€ (revenue-type metrics).

class emflow.problems.objective.RootMeanSquaredError[source]๏ƒ

Bases: MeanSquaredError

aggregate: str = 'mean'๏ƒ

How per-origin scores combine into an overall score: โ€œmeanโ€ (pooled by scored timestamps โ€” error metrics) or โ€œsumโ€ (revenue-type metrics).

calculate(y_true, y_pred) float๏ƒ
elementwise(y_true, y_pred)๏ƒ

Per-timestamp scores (NaN where either side is missing).

property name๏ƒ
class emflow.problems.objective.MeanAbsolutePercentageError[source]๏ƒ

Bases: Metric

elementwise(y_true, y_pred)[source]๏ƒ

Per-timestamp scores (NaN where either side is missing).

aggregate: str = 'mean'๏ƒ

How per-origin scores combine into an overall score: โ€œmeanโ€ (pooled by scored timestamps โ€” error metrics) or โ€œsumโ€ (revenue-type metrics).

calculate(y_true, y_pred) float๏ƒ
property name: str๏ƒ
class emflow.problems.objective.PinballLoss(quantiles: Sequence[float] | None = None)[source]๏ƒ

Bases: Metric

Average pinball (quantile) loss over the predictionโ€™s quantile columns.

y_pred must carry quantile levels as float column names. If the metric was constructed with explicit quantiles, the prediction must provide exactly those columns (competition contract); otherwise whatever quantile columns are present are scored.

elementwise(y_true, y_pred)[source]๏ƒ

Per-timestamp pinball loss, averaged across quantiles.

aggregate: str = 'mean'๏ƒ

How per-origin scores combine into an overall score: โ€œmeanโ€ (pooled by scored timestamps โ€” error metrics) or โ€œsumโ€ (revenue-type metrics).

calculate(y_true, y_pred) float๏ƒ
property name: str๏ƒ
class emflow.problems.objective.PeakTimingError[source]๏ƒ

Bases: Metric

BigDEAL-2022-style peak-timing score: per day, the absolute distance (in hours) between the true and predicted peak hour of y.

Both series are grouped by calendar day on their index; days missing from either side are skipped.

elementwise(y_true, y_pred)[source]๏ƒ

Per-timestamp scores (NaN where either side is missing).

aggregate: str = 'mean'๏ƒ

How per-origin scores combine into an overall score: โ€œmeanโ€ (pooled by scored timestamps โ€” error metrics) or โ€œsumโ€ (revenue-type metrics).

calculate(y_true, y_pred) float๏ƒ
property name: str๏ƒ