--- 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