--- 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.51 - name: MAPE type: mape value: 7.14 - name: R2 type: r2 value: 0.8633 --- # Store Sales Forecasting Model ## Model Overview This is an Improved Cash Flow LSTM model for forecasting store sales over a 13-week horizon, trained on the Kaggle Store Sales dataset. ## Model Architecture - **Type**: LSTM - **Input Size**: 20 - **Hidden Size**: 128 - **Number of Layers**: 2 - **Dropout**: 0.2 - **Forecast Horizon**: 13 weeks - **Parameters**: 227,085 ## Features Used 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.51 - **MAPE**: 7.14% - **R² Score**: 0.8633 ## Usage 1. Install dependencies: `pip install -r requirements.txt` 2. Use `inference.py` to load the model and make predictions. 3. Input data must have 21 timesteps and match the feature set, scaled using `scaler.pkl`. ### Example ```python import numpy as np from inference import load_model_and_artifacts, forecast model, scaler, feature_names = load_model_and_artifacts() sequences = np.random.random((1, 21, len(feature_names))) # Replace with actual data predictions, uncertainties = forecast(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**: 107 (early stopping) - **Optimizer**: Adam with ReduceLROnPlateau - **Loss**: MSE ## Limitations - Predictions are sensitive to input data quality. - Model assumes consistent feature scaling. - Performance may degrade on sparse or outlier-heavy data. ## License MIT License