File size: 2,862 Bytes
07e5e40 84d195f 07e5e40 84d195f 07e5e40 84d195f 114df8f 84d195f 114df8f 84d195f 07e5e40 114df8f 84d195f 114df8f 84d195f 114df8f 84d195f 114df8f 84d195f 114df8f 84d195f 114df8f 84d195f 114df8f 84d195f 114df8f 84d195f 114df8f 84d195f 114df8f 84d195f 114df8f 84d195f 114df8f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
---
title: Store Sales Time Series Forecasting
emoji: 📈
colorFrom: blue
colorTo: green
sdk: docker
sdk_version: 1
app_file: app.py
pinned: false
short_description: Forecast store sales over 13 weeks using LSTM
license: mit
tags:
- time-series
- forecasting
- lstm
- retail
- pytorch
library_name: pytorch
model-index:
- name: ImprovedCashFlowLSTM
results:
- task:
type: time-series-forecasting
dataset:
name: Kaggle Store Sales
type: store-sales-time-series-forecasting
metrics:
- name: MAE
type: mae
value: 710.75
- name: RMSE
type: rmse
value: 1108.36
- name: MAPE
type: mape
value: 7.16
- name: R2
type: r2
value: 0.8633
---
# Store Sales Time Series Forecasting
## Overview
This Hugging Face Space hosts an LSTM-based model (`ImprovedCashFlowLSTM`) for forecasting store sales over a 13-week horizon, trained on the Kaggle Store Sales Time Series Forecasting dataset.
## Model Architecture
- **Type**: LSTM
- **Input Size**: 20 features
- **Hidden Size**: 128
- **Number of Layers**: 2
- **Dropout**: 0.2
- **Forecast Horizon**: 13 weeks
- **Parameters**: 227,441
- **Features**: sales, onpromotion, trend, dayofweek_sin, dayofweek_cos, month_sin, month_cos, is_weekend, quarter, sales_lag_1, sales_lag_7, sales_lag_14, sales_ma_7, sales_ma_14, sales_ratio_7, sales_ratio_14, promo_lag_1, promo_running_sum, dcoilwtico, is_holiday
## Performance Metrics
- **MAE**: $710.75
- **RMSE**: $1108.36
- **MAPE**: 7.16%
- **R² Score**: 0.8633
## Usage
1. **Synthetic Data**: Click "Generate Synthetic Data" to create a 21-timestep sample dataset (sales ~$3,000–19,000) and view a 13-week forecast.
2. **Custom Data**: Upload a CSV with 21 timesteps and 20 features matching the above feature names.
3. **Output**: View forecasts in a table and Plotly graph with uncertainty bands.
### Example
```python
from inference import load_model_and_artifacts, predict
model, scaler, feature_names, config = load_model_and_artifacts()
sequences = scaler.transform(your_data[feature_names].values).reshape(1, 21, 20)
predictions, uncertainties = predict(model, scaler, sequences)
print("Predictions:", predictions)
```
## Training Details
- **Dataset**: Kaggle Store Sales Time Series Forecasting
- **Data Shape**: (8250, 20)
- **Sequences**: 8217, length 21
- **Preprocessing**: StandardScaler, conservative outlier removal
- **Epochs**: 70 (early stopping)
- **Optimizer**: Adam with ReduceLROnPlateau
- **Loss**: MSE
## Limitations
- Predictions are sensitive to input data quality and scaling.
- Performance may degrade on low-sales stores (<$3,000) not included in training.
- Assumes consistent feature engineering as in training.
## License
MIT License |