Skip to main content

Timing-aware metric for intermittent demand forecasting

Project description

pip install intermittent_alignment_error

Intermittent Alignment Error
Timing-aware evaluation for intermittent demand forecasts

This repository contains the reference implementation of Intermittent Alignment Error (IAE), a metric for evaluating intermittent demand forecasts when both timing and magnitude matter.

IAE is most useful when forecasts are expressed in the same unit as the original time-series, with zero-demand periods and non-zero demand events across a forecasting horizon. It is designed for point forecasts and is especially useful when comparing models across heterogeneous intermittent time-series.

For a quick start, see the example.ipynb notebook in this repository.


Examples

The examples below illustrate how the metric behaves under different types of forecasting errors.

Early and late forecasts

Early forecast example Late forecast example
Forecast shifted early.
The forecast is close in time to the ground truth and arrives before demand occurs, which tends to keep the in-time error low.
Forecast shifted late.
The forecast may still be close in time to the ground truth, but demand is not covered before it occurs, which increases the in-time error.

Metric components

Recall and precision components Mass and in-time components
Recall and precision error.
Recall error measures how well actual demand events are captured by the forecast. Precision error measures how well forecasted demand is supported by actual demand.
Mass and in-time error.
Mass error measures whether the total demand over the horizon is correct. In-time error measures whether enough demand has been forecasted before actual demand occurs.

Standard timing-aware setting

Standard IAE error matrix

This figure shows how the metric behaves under different combinations of timing and magnitude errors for three different ADI scenarios. Each matrix visualises the average metric score when forecasts are shifted earlier or later in time and scaled up or down in demand size, illustrating how the standard IAE setting responds to different types of forecasting errors across varying levels of intermittency.


Demand rate setting

Some forecasting methods, such as Croston-style demand rate forecasts, are not intended to predict exact event timing. In that case, the metric can be configured to focus only on mass and in-time.

Demand rate forecast example

Demand rate forecast example

Demand rate metric matrix

Demand rate metric matrix

To use the demand rate setting, turn off recall and precision by setting their weights to zero:

metric_params = {
    "recall_weight": 0.0,
    "precision_weight": 0.0,
    "mass_weight": 1.0,
    "in_time_weight": 1.0,
    "p": 2.0,
    "in_time_relevance_mode": "linear",
}

This configuration is appropriate when the forecast is intended to represent a rate or cumulative coverage over the horizon rather than exact local alignment of demand events.


The version of the metric used in the licentiate thesis Decision Support through Global Demand Forecasting is preserved in the licentiate_thesis branch. The main branch contains the current version of the implementation.

License

This work is licensed under the Creative Commons Attribution-NonCommercial 4.0 International License (CC BY-NC 4.0).

Please cite the corresponding paper when using this metric in academic work.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

intermittent_alignment_error-0.1.2.tar.gz (14.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

intermittent_alignment_error-0.1.2-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

Details for the file intermittent_alignment_error-0.1.2.tar.gz.

File metadata

File hashes

Hashes for intermittent_alignment_error-0.1.2.tar.gz
Algorithm Hash digest
SHA256 eb0b48121beab664bbd7765c0b9eebc06666be419fbe2763aff6719a4c53cfa6
MD5 02e5011c4549571857602ac2b0be7913
BLAKE2b-256 dee5ba2b96753e6bcfd668692fc8cd5c8c4c3477c39bc20f05b0fd40c9fa9dea

See more details on using hashes here.

File details

Details for the file intermittent_alignment_error-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for intermittent_alignment_error-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 40f651f3afaad57897cbafdbdf1a6fb425853103a4c0961c01be71ba1575b6cd
MD5 cc510c968559f4a172dd4fbd16dba11c
BLAKE2b-256 f107a20b8c2091b23f91daa46bdab76cc7dc15707ae9d852c80feb2d85c16a8a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page