Skip to main content

This package is a set of metrics commonly used to analyze the performance of predictive models for time series, such as MAPE, Theil's U, ARV, ID (Index of Disagreement), wpocid.

Project description

Timeseries Metrics

This package provides several metrics used to evaluate the performance of predictive models in time series.

Installation

You can install the package using pip:

pip install timeseriesmetrics

Usage

The package can be used as follows:

from timeseriesmetrics import *

y_true = [1, 2, 3, 4, 5]
y_pred = [3, 4, 3, 4, 5]

theil(y_true, y_pred)

Where y_true represents the real values ​​and y_pred the predicted values.

Definitions

  • $ N $: number of observations.
  • $ u_{t} $: real values.
  • $ \widehat{u}_{t} $: predicted values.
  • $ \overline{u}_{t} $: mean of the real values.

Available Metrics

MAPE

MAPE (Mean Absolute Percentage Error) measures the accuracy of the model, presenting a relative value:

$$ MAPE = \frac{100}{N} \sum_{t=1}^{N} \left| \frac{u_{t} - \widehat{u}{t}}{u{t}} \right| $$

ARV

ARV (Average Relative Variance) compares the predictor's performance with the simple average of past values ​​in the series:

$$ ARV = \frac{\sum_{t=1}^{N} \left( u_{t} - \widehat{u}{t} \right)^{2}}{\sum{t=1}^{N} \left( \widehat{u}{t} - \overline{u}{t} \right)^{2}} $$

ID

ID (Index of Disagreement) disregards the unit of measurement, presenting values ​​in the interval [0, 1]:

$$ ID = \frac{\sum_{t=1}^{N} \left( \widehat{u}{t} - u{t} \right)^{2}}{\sum_{t=1}^{N} \left( \left| \widehat{u}{t} - \overline{u}{t} \right| + \left| u_{t} - \overline{u}_{t} \right| \right)^{2}} $$

Theil'U

Theil'U compares prediction performance to the Random Walk model (in which $ u_{t} $ is inferred by $ u_{t-1} $), where Theil< 1 indicates a better prediction than the Random Walk model:

$$ Theil = \frac{\sum_{t=2}^{N} \left( u_{t} - \widehat{u}{t} \right)^{2}}{\sum{t=2}^{N} \left( u_{t} - u_{t-1} \right)^{2}} $$

WPOCID

WPOCID measures how well the model predicts the trend of the target time series:

$$ \left.\begin{aligned} & WPOCID = 1 - \frac{\sum_{t=2}^{N} D_{t}}{N-1}, \ & D_{t} = \left{ \begin{array}{l} 1, \text{ se } \left( u_{t} - u_{t-1} \right) \left( \widehat{u}{t} - \widehat{u}{t-1} \right) \geq 0 \ 0, \text{ se } \left( u_{t} - u_{t-1} \right) \left( \widehat{u}{t} - \widehat{u}{t-1} \right) < 0 \end{array} \right. \end{aligned}\right. $$

References

More details on the metrics discussed can be found in the article A non-central beta model to forecast and evaluate pandemics time series.

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

timeseriesmetrics-0.1.0.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

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

timeseriesmetrics-0.1.0-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file timeseriesmetrics-0.1.0.tar.gz.

File metadata

  • Download URL: timeseriesmetrics-0.1.0.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.4

File hashes

Hashes for timeseriesmetrics-0.1.0.tar.gz
Algorithm Hash digest
SHA256 23930f4bcafa342138899f6000e86524268cc5c94d57baf5c52e629eaf209311
MD5 e68429b6491aa471794de2f105f5ee71
BLAKE2b-256 ef6f2f1b7a7de2dd76d0daae4d5d5aad136ed923445c37e7abe72587c4413ae8

See more details on using hashes here.

File details

Details for the file timeseriesmetrics-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for timeseriesmetrics-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 17e6d0b39860b6a2f940a22a6584f3e9bbe4883e9ad12a2754beefbb13acfa92
MD5 b6caef1d32c156fcc3976b0deb7e5441
BLAKE2b-256 7c3a9b4b90e83a341ad607197ae720a63dd46fabe311b36769fe05c0c2c03649

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