Intelligent Inventory Management: Comparing Prophet and LSTM for Time‑Series Forecasting

This article presents an intelligent inventory management solution that predicts product consumption using two time‑series algorithms—Facebook's Prophet and LSTM deep learning—detailing data sources, preprocessing, model configuration, evaluation metrics, and a comparative analysis of their performance and suitability.

Fulu Network R&D Team
Fulu Network R&D Team
Fulu Network R&D Team
Intelligent Inventory Management: Comparing Prophet and LSTM for Time‑Series Forecasting

Background : FuLu Network provides various recharge services (telecom, gaming, lifestyle) and faces challenges in managing inventory turnover and capital efficiency. To address this, an intelligent inventory management service is proposed that predicts daily consumption of each product based on order and product data.

Algorithm Selection : Two mature time‑series forecasting methods are recommended: Facebook's open‑source Prophet algorithm and an LSTM deep‑learning model. Their key characteristics are compared, highlighting training time, ease of use, data requirements, and multi‑dimensional capability.

Data Sources : The model uses (1) order data and (2) product classification data. The data format is a CSV with columns time,product,cnt where time is hourly, product is the product or category name, and cnt is the number of successful orders.

Feature Processing : Generally, time‑series data is used without additional features, though optional normalization or log‑transformation can be applied.

Prophet Details : Prophet is a commercial‑oriented statistical model that handles trend, seasonality, and holidays. The tuning steps include outlier removal, trend model selection (linear or logistic), changepoint specification, seasonal component configuration, and holiday effects. Grid‑search is recommended for hyper‑parameter optimization.

Prophet Code Example :

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from fbprophet import Prophet

data = pd.read_csv('../data/data2.csv', parse_dates=['time'], index_col='time')

def get_product_data(name, rule=None):
    product = data[data['product'] == name][['cnt']]
    if rule is not None:
        product = product.resample(rule).sum()
    product.reset_index(inplace=True)
    product.columns = ['ds', 'y']
    return product

holidays = pd.read_csv('holiday.csv', parse_dates=['ds'])
holidays['lower_window'] = -1
holidays = holidays.append(pd.DataFrame({
    'holiday': ['双11', '双12'],
    'ds': pd.to_datetime(['2019-11-11', '2020-11-11', '2019-12-12', '2020-12-12']),
    'lower_window': -1,
    'upper_window': 1
}))

m = Prophet(holidays=holidays)
# ... fit and predict ...

LSTM Details : LSTM (Long Short‑Term Memory) networks are RNN variants designed for sequential data, featuring input, forget, and output gates. They can model multi‑dimensional time series and are suitable when large amounts of data are available.

LSTM Code Example :

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import torch
from torch import nn
from sklearn.preprocessing import MinMaxScaler

ts_data = pd.read_csv('../data/data2.csv', parse_dates=['time'], index_col='time')

def series_to_supervised(data, n_in=1, n_out=1, dropnan=True):
    # Convert series to supervised learning format
    df = pd.DataFrame(data)
    cols, names = [], []
    for i in range(n_in, 0, -1):
        cols.append(df.shift(i))
        names += [f'var{j+1}(t-{i})' for j in range(df.shape[1])]
    for i in range(0, n_out):
        cols.append(df.shift(-i))
        if i == 0:
            names += [f'var{j+1}(t)' for j in range(df.shape[1])]
        else:
            names += [f'var{j+1}(t+{i})' for j in range(df.shape[1])]
    agg = pd.concat(cols, axis=1)
    agg.columns = names
    if dropnan:
        agg.dropna(inplace=True)
    return agg

# Transform data for LSTM
scaler = MinMaxScaler((0,1))
yd = ts_data[ts_data['product']=='移动话费'][['cnt']]
yd_scaled = scaler.fit_transform(yd.values)
yd_supervised = series_to_supervised(yd_scaled, n_in=2).values.astype('float32')
# Split, reshape, convert to torch tensors, define model, train, etc.
class lstm_reg(nn.Module):
    def __init__(self, input_size, hidden_size, output_size=1, num_layers=2):
        super(lstm_reg, self).__init__()
        self.rnn = nn.LSTM(input_size, hidden_size, num_layers)
        self.reg = nn.Linear(hidden_size, output_size)
    def forward(self, x):
        x, _ = self.rnn(x)
        s, b, h = x.shape
        x = x.view(s*b, h)
        x = self.reg(x)
        x = x.view(s, b, -1)
        return x
# ... training loop ...

Comparison : Prophet trains in seconds, requires no feature engineering, and works well with limited data; LSTM needs hours of training, extensive feature preprocessing, and large datasets but can capture multi‑dimensional relationships. The article provides quantitative error metrics (mean, max, min, 0.9‑quantile, etc.) and categorizes product‑algorithm fit into three types based on historical error thresholds.

Conclusion : For most inventory items with sparse data, Prophet offers a fast, reliable solution, while LSTM may be justified for high‑volume products where richer features and longer training are acceptable. References to Prophet documentation, papers, and LSTM tutorials are included.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

machine learningdata analysisTime SeriesLSTMProphetinventory forecasting
Fulu Network R&D Team
Written by

Fulu Network R&D Team

Providing technical literature sharing for Fulu Holdings' tech elite, promoting its technologies through experience summaries, technology consolidation, and innovation sharing.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.