Skip to content
Other

SibangiS/hf-inventory-demand-forecaster

7-day retail demand forecasting and reorder calculator

2 min readupdated

A hybrid stacking ensemble (combining multiple algorithms under a meta-model) that predicts total 7-day demand for a specific product at a given store. It takes historical CSV sales data and outputs a demand forecast alongside recommended reorder quantities adjusted for safety stock. Under the hood, tuned LightGBM and XGBoost gradient boosting models are blended by a HuberRegressor meta-model — the author dropped the LSTM model in this release after the two-booster combo achieved lower error. Useful for data analysts and inventory management developers looking for a ready-to-run pipeline or a tabular forecasting baseline.

Key features

  • Uses 49 leak-free features: sales lags, 7-, 14-, and 28-day rolling averages and standard deviations, competitor prices, discounts, seasonality, and weather.
  • The HuberRegressor meta-model (weighted 0.5785 for LightGBM and 0.3456 for XGBoost) is trained strictly on out-of-fold validation and beats individual models on MAE and RMSE.
  • Automatically calculates safety stock (at the 90th percentile of errors — 181.75 units), lifting the test service level to 91.14%.
  • Bundles the entire pipeline and preprocessor into a single hybrid_ensemble.pkl file, while keeping earlier versions and training scripts in the repo for comparison.

What you can do

  • Run the ready-made predict.py script on historical sales tables (at least 28 rows per store–product pair) to generate demand forecasts and reorder quantities.
  • Use the feature engineering and ensemble architecture as a starting point for custom retail forecasting tasks by fine-tuning on real-world data.
  • Compare classic gradient boosting against LSTM on tabular time series using the pre-computed benchmarks in leaderboard.csv.

Example

pip install -r requirements.txt
python predict.py --history sample_input.csv
Read moreDetails
Test metrics (8,400 rows): MAE — 105.30 (vs. 141.86 for the seasonal baseline and 106.61 for v1 Ridge), RMSE — 138.13, WMAPE — 0.1460.
Training: 64,200 rows from a synthetic Kaggle dataset (5 stores, 20 products, 2022–2024).
Limitations: trained on synthetic data, does not account for product shelf life, and is intended for research rather than direct production use without validation on real sales.
Discuss Telegram 1 32

Will it run?

Working out the memory needs

The bot is still collecting this model's weight sizes; the estimate will appear here in a few minutes. Meanwhile you can rent a GPU with headroom.

Massed ComputeOpen Massed Compute

Run it on Massed Compute

The script downloads the model to the rented machine. How to run it is in the model card.

  1. 1. Rent a machine with a fitting GPU

    Open Massed Compute
  2. 2. Paste the script into the machine's terminal

    Connect over SSH (the Massed Compute panel shows the command) or open a terminal on the machine's desktop.

    HF_TOKEN / CIVITAI_TOKENThe script starts with token lines: paste yours between the quotes. The Hugging Face token is for gated models, the Civitai one for Civitai models.

    # SibangiS/hf-inventory-demand-forecaster
    mkdir -p ~/models
    curl -LsSf https://astral.sh/uv/install.sh | sh
    source "$HOME/.local/bin/env"
    uv tool install "huggingface_hub[cli]"
    hf download SibangiS/hf-inventory-demand-forecaster --local-dir ~/models/hf-inventory-demand-forecaster
    # The model is in ~/models. How to run it is in the model card (link above).
  3. 3. Use it

    The model is in ~/models. How to run it is in the model card (link above).

Stop the machine in the panel when you are done: it bills by the minute while it runs.

How to speed it up

Picked for this model type. Choose your hardware above to see what fits you exactly.

  • FlashAttention 44.0.0b40from November 18, 2026new release

    fastest exact attention on B200

    Kernels for Blackwell (beta). Exact attention without quantisation — fine for everything, LLMs included.

    How to enable: pip install flash-attn-4; vLLM and SGLang pick it up themselves.

    Earlier generations (2)
    • FlashAttention 3 — The Hopper (H100/H200) version with FP8.
    • FlashAttention 2 — The standard for RTX 30/40/50 and A100: exact attention without the memory cost of long contexts.
  • torch.compile2.15.0from October 28, 2026new release

    10–30% for free

    Compiles the model for your GPU. Slower first run, faster afterwards.

    How to enable: model = torch.compile(model); in ComfyUI the TorchCompileModel node.

Model family

New posts about versions of hf-inventory-demand-forecaster (quants, finetunes, LoRAs) will show up under the bell.

No known relatives of this model yet. All derivatives on Hugging Face

About the model

SibangiS/hf-inventory-demand-forecaster
Author
SibangiS
Category
Other
Released
Posted

On NeyroLearn

Hugging Face

321

Ask AI about this model

Answered by Gemini 4 · the chat is kept only in this tab

Comments