Visual and quantitative metric for evaluating time series forecasts
Project description
Overlay_dx
Visual and quantitative metric for evaluating time series forecasts
Overlay_dx is a novel evaluation metric that combines visual interpretability with quantitative assessment. It measures the alignment between predicted and actual values across different tolerance thresholds, providing both intuitive visualization and a numerical score.
Features
- Visual interpretation through overlay curves
- Quantitative assessment via area under curve (AUC) score
- Less sensitive to outliers than MSE/RMSE
- Scikit-learn compatible - works with cross_val_score, GridSearchCV, Pipeline
- Easy to use with minimal setup
Installation
pip install overlay-dx
Quick Start
from overlay_dx import overlay_dx_score
import numpy as np
# Your predictions and actual values
y_true = np.array([1, 2, 3, 4, 5])
y_pred = np.array([1.1, 2.1, 2.9, 4.1, 5.1])
# Calculate overlay_dx score
score = overlay_dx_score(y_true, y_pred)
print(f"Overlay_dx score: {score:.3f}")
# Output: Overlay_dx score: 0.930
Scikit-learn Integration
from overlay_dx import make_overlay_dx_scorer
from sklearn.model_selection import cross_val_score
from sklearn.ensemble import RandomForestRegressor
# Create scorer
scorer = make_overlay_dx_scorer()
# Use with cross-validation
model = RandomForestRegressor()
scores = cross_val_score(model, X, y, scoring=scorer, cv=5)
print(f"CV scores: {scores.mean():.3f} (+/- {scores.std():.3f})")
With GridSearchCV
from overlay_dx import OVERLAY_DX_SCORER
from sklearn.model_selection import GridSearchCV
param_grid = {'n_estimators': [50, 100, 200]}
grid = GridSearchCV(
RandomForestRegressor(),
param_grid,
scoring=OVERLAY_DX_SCORER,
cv=5
)
grid.fit(X_train, y_train)
print(f"Best score: {grid.best_score_:.3f}")
How It Works
Overlay_dx measures the percentage of predictions falling within tolerance intervals of varying sizes around actual values. It then computes the area under the resulting curve, normalized by the maximum possible area.
Key advantages:
- Intuitive visual interpretation
- Robust to outliers
- Captures performance across multiple tolerance levels
- Easy to explain to non-technical stakeholders
Research Paper
Overlay_dx is based on peer-reviewed research published at OLA 2025:
"Overlay_dx - Automating forecasting evaluation"
Long H. Ngo, Mohammed Amine Chamli, Jonathan Rivalan, and Thomas Jaillon
4th International Conference on Optimization and Learning Algorithms (OLA 2025)
The paper demonstrates overlay_dx effectiveness across multiple public datasets (Beijing Air Quality, ETT, ELD) and compares it with traditional metrics (MAE, RMSE, MAPE, etc.).
API Reference
overlay_dx_score(y_true, y_pred, max_percentage=100, min_percentage=0.1, step=0.1)
Calculate overlay_dx score.
Parameters:
y_true: array-like, actual valuesy_pred: array-like, predicted valuesmax_percentage: float, maximum tolerance percentage (default: 100)min_percentage: float, minimum tolerance percentage (default: 0.1)step: float, step size for tolerance levels (default: 0.1)
Returns:
score: float between 0 and 1, higher is better
make_overlay_dx_scorer(max_percentage=100, min_percentage=0.1, step=0.1)
Create a scikit-learn scorer object.
Returns:
scorer: callable compatible with sklearn model selection tools
Pre-configured scorers
OVERLAY_DX_SCORER: Default configurationOVERLAY_DX_SCORER_FINE: Fine-grained (step=0.01)OVERLAY_DX_SCORER_COARSE: Coarse-grained (step=1.0)
Advanced Usage
Custom Parameters
from overlay_dx import make_overlay_dx_scorer
# Create scorer with custom tolerance range
scorer = make_overlay_dx_scorer(
max_percentage=50, # Only test up to 50% of range
min_percentage=0.5,
step=0.5
)
Using the Evaluate Class
from overlay_dx import Evaluate
evaluator = Evaluate(target_values=y_true, prediction=y_pred)
# Get various metrics
mae = evaluator.mae()
rmse = evaluator.rmse()
overlay_score = evaluator.overlay_dx_area_under_curve_metric(
forecast=y_pred,
max_percentage=100,
min_percentage=0.1,
step=0.1
)
Requirements
- Python >= 3.8
- numpy >= 1.20.0
- scikit-learn >= 1.0.0
- matplotlib >= 3.3.0
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT License - see LICENSE file for details.
Citation
If you use overlay_dx in your research, please cite:
@inproceedings{ngo2025overlaydx,
title={Overlay_dx - Automating forecasting evaluation},
author={Ngo, Long H. and Chamli, Mohammed Amine and Rivalan, Jonathan and Jaillon, Thomas},
booktitle={4th International Conference on Optimization and Learning Algorithms (OLA)},
year={2025}
}
Links
- GitHub: https://github.com/Smile-SA/overlay_dx
- PyPI: https://pypi.org/project/overlay-dx/
- Documentation: https://github.com/Smile-SA/overlay_dx#readme
- Paper: https://ola2025.sciencesconf.org/
Authors
Developed by the R&D team at Smile.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file overlay_dx-0.1.0.tar.gz.
File metadata
- Download URL: overlay_dx-0.1.0.tar.gz
- Upload date:
- Size: 13.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e9b8cea768df840f71805f496f616c49906660ba2f6fbc52c4826dce70a0894e
|
|
| MD5 |
c8c4052ffca21d94cbf86e05f8144218
|
|
| BLAKE2b-256 |
a3a64a3190163d5c83a54b9b6a27fc8cacffdf8d2ca5409cd685e02e0d25f75e
|
File details
Details for the file overlay_dx-0.1.0-py3-none-any.whl.
File metadata
- Download URL: overlay_dx-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2178f201dc4665f96f6a1768a1a0707eb5012a3a58352a85a16c44718d6da317
|
|
| MD5 |
2d0fb034f70c378dd2e268d60db7750a
|
|
| BLAKE2b-256 |
07f9eb95d86a8d988f572d0b9dc7865ab3c4276a9f475c0997b099c5c21c1215
|