A time-series forecasting model using UR2CUTE.
Project description
UR2CUTE
Using Repetitively 2 CNNs for Unsteady Timeseries Estimation
UR2CUTE is a specialized forecasting model designed for intermittent time series data. By employing a dual CNN approach, it effectively addresses the challenges of predicting both the occurrence and magnitude of demand in irregular time series patterns.
📋 Overview
Intermittent demand forecasting presents unique challenges due to irregular and unpredictable demand patterns, characterized by periods of zero demand followed by random non-zero demand. Traditional forecasting methods often perform poorly on such data.
UR2CUTE employs a two-step approach:
- A CNN-based classification model predicts demand occurrence (zero vs. non-zero)
- A CNN-based regression model estimates the magnitude of demand
This dual-phase approach significantly improves forecasting accuracy for intermittent demand, particularly in predicting periods of zero demand.
🔍 Features
- Two-Step Prediction Process: Separate models for order occurrence and quantity prediction
- Temporal Pattern Recognition: CNNs effectively capture temporal patterns in intermittent data
- Lag Feature Generation: Automatically creates lagged features to capture historical dependencies
- Combined Loss Function: Custom loss functions optimized for each prediction task
- Sklearn Compatibility: Follows scikit-learn API conventions for easy integration
- Direct Multi-Step Forecasting: Predicts multiple future time steps in one pass
🛠️ Installation
pip install prevail
Then import the model:
from prevail.models import UR2CUTE
📊 Quick Start
import pandas as pd
from prevail.models import UR2CUTE
# Load time series data
df = pd.DataFrame({
'date': pd.date_range('2023-01-01', periods=50, freq='W'),
'target': [0, 5, 0, 0, 12, 0, 0, 0, 7, 0, ...], # Intermittent data
'feat1': [...], # Optional external features
'feat2': [...] # Optional external features
})
# Initialize model
model = UR2CUTE(
n_steps_lag=3,
forecast_horizon=4,
external_features=['feat1', 'feat2']
)
# Fit model
model.fit(df, target_col='target')
# Make predictions for the next forecast_horizon steps
predictions = model.predict(df)
print("Predicted values:", predictions)
🔧 Parameters
| Parameter | Description | Default |
|---|---|---|
n_steps_lag |
Number of lag features to generate | 3 |
forecast_horizon |
Number of future steps to predict | 8 |
external_features |
List of column names for external features | None |
epochs |
Training epochs for both CNN models | 100 |
batch_size |
Batch size for training | 32 |
threshold |
Probability threshold for classifying zero vs. non-zero | 0.5 |
patience |
Patience for EarlyStopping | 10 |
random_seed |
Random seed for reproducibility | 42 |
classification_lr |
Learning rate for classification model | 0.0021 |
regression_lr |
Learning rate for regression model | 0.0021 |
dropout_classification |
Dropout rate for classification model | 0.4 |
dropout_regression |
Dropout rate for regression model | 0.2 |
📝 Methods
fit(df, target_col)
Fits the UR2CUTE model on the time series data.
Parameters:
df(pandas.DataFrame): Time series data with at least the target column. Must be sorted by time.target_col(str): The name of the column to forecast.
Returns:
- The fitted UR2CUTE model instance.
predict(df)
Predicts the next forecast_horizon steps from the input DataFrame.
Parameters:
df(pandas.DataFrame): Time series data with the same columns as used in fit(). Must be sorted by time.
Returns:
- numpy.ndarray: The predictions for each step in the horizon.
🔍 How It Works
-
Data Preprocessing:
- Aggregates demand data (e.g., daily to weekly)
- Generates lag features to capture historical patterns
-
Model Architecture:
- Classification Model: CNN that predicts probability of non-zero demand
- Regression Model: CNN that predicts quantity when demand exists
-
Prediction Process:
- Classification model predicts if demand will occur
- Regression model predicts the magnitude of demand
- Final prediction combines both models' outputs
🏆 Performance
UR2CUTE outperforms traditional forecasting techniques including:
- Croston's method
- XGBoost
- Random Forest
- ETR
- Prophet
- AutoARIMA
Particularly for predicting intermittent demand, UR2CUTE shows significant improvements in:
- Mean Absolute Error % (MAE%)
- Root Mean Square Error % (RMSE%)
- R-squared values
📚 Citation
If you use UR2CUTE in your research, please cite:
@article{mirshahi2024intermittent,
title={Intermittent Time Series Demand Forecasting Using Dual Convolutional Neural Networks},
author={Mirshahi, Sina and Brandtner, Patrick and Kom{\'i}nkov{\'a} Oplatkov{\'a}, Zuzana},
journal={MENDEL — Soft Computing Journal},
volume={30},
number={1},
year={2024},
publisher={MENDEL Journal}
}
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
👥 Contributors
- Sina Mirshahi
- Patrick Brandtner
- Zuzana Komínková Oplatková
🙏 Acknowledgments
This research was conducted at:
- Department of Informatics and Artificial Intelligence, Tomas Bata
- Department for Logistics, University of Applied Sciences Upper Austria, Steyr
- Josef Ressel-Centre for Predictive Value Network Intelligence, Steyr
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 fh_prevail-0.1.0.tar.gz.
File metadata
- Download URL: fh_prevail-0.1.0.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.10.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6bce5cc9401b89ccf030f0108c9b00f424857a21e5fa6616cd3b425530028f17
|
|
| MD5 |
b109a03a043da968b64cf9036dcb1072
|
|
| BLAKE2b-256 |
74c77d2116a381327b691d860da5e6c49248fa35832d1154c2c5ad3de3556cd7
|
File details
Details for the file fh_prevail-0.1.0-py3-none-any.whl.
File metadata
- Download URL: fh_prevail-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.10.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
61f6bf2ce4f6f9e9e00a4b5b7d89dd251dafc2556f399983f55d1a680fe3fd93
|
|
| MD5 |
ee0393ae8afd8ce6d42d3e67f3e8c4d0
|
|
| BLAKE2b-256 |
ce43879e240bdb0dec538ade121a9ca4444e7c15b2ec99398e0698811e9c92c9
|