Applied Sciences (Oct 2024)

Sales Forecasting with LSTM, Custom Loss Function, and Hyperparameter Optimization: A Case Study

  • Hyasseliny A. Hurtado-Mora,
  • Alejandro H. García-Ruiz,
  • Roberto Pichardo-Ramírez,
  • Luis J. González-del-Ángel,
  • Luis A. Herrera-Barajas

DOI
https://doi.org/10.3390/app14219957
Journal volume & issue
Vol. 14, no. 21
p. 9957

Abstract

Read online

Forecasting sales trends is a valuable activity for companies of all types and sizes, as it enables more efficient decision making to avoid unnecessary expenses from excess inventory or, conversely, losses due to insufficient inventory to meet demand. In this paper, we designed a personalized cost function to reduce economic losses caused by the excessive acquisition of products or derived from their scarcity when needed. Moreover, we designed an LSTM network integrated with Glorot and Orthogonal initializers and dropout to forecast sales trends in a lumber mill in Tamaulipas, Mexico. To generalize and appropriately forecast the sales of the lumber mill products, we optimized the LSTM network’s hyperparameters through a genetic algorithm, which was essential to explore the solution space. We evaluated our proposal in instances obtained from the historical sales of the five main products sold by the lumber mill. According to the results, we concluded that for our case study the proposed function cost and the hyperparameters optimization allowed the LSTM to forecast the direction and trend of the lumber mill’s product sales despite the variability of the products.

Keywords