# Demand Forecasting in Supply Chain Using Uni-Regression Deep Approximate Forecasting Model
## 4 Proposed Uni-Regression Deep Approximate Forecasting Model (UDAF) in Demand Forecasting
#### NARX Model  
The NARX model captures dependencies based on historical demand data \(B_{t-1}\) and exogenous inputs \(A_{c}\). \[\overset{\wedge}{t}c=e\big{(}t_{c-1},t_{c-2},\ldots\ldots t_{c-s},a_{c-1},a_{c -2},\ldots\ldots a_{c-j}\big{)}+\ \in_{c} \tag{17}\]  
In this case, \(\overset{\wedge}{t}c\) corresponds to the forecast demand at time \(c\), and \(e\) is a nonlinear function used for describing relations between lagged demands based on exogenous inputs. \(\varepsilon_{c}\) is the error term. NARXNN is a model that incorporates NARX-SP feedback for better accuracy and effective training. Simulations have confirmed that the NARXNN is more effective than conventional methods such as feed-forward and Elman networks in identifying the patterns of sequential output. This improved performance is credited to the utilization of tapped-delay lines for inserting input vectors, which enables faster propagation paths during the gradient descent process. However, the computational resources required for NARXNN are significantly reduced when the output memory is eliminated. Additionally, NARXNN, as part of the RNN, faces the vanishing gradient problem to some extent. This problem occurs when the RNN stops learning after a certain number of inputs, leading to a decrease in prediction accuracy due to fading memory caused by the shrinking gradient descent. 1. Recurrent Bidirectional Long Short-Term Memory (BiLSTM) Network To tackle issues like the vanishing gradient problem and the decrease in prediction accuracy due to fading memory caused by the shrinking gradient descent, LSTM was introduced. LSTM replaces nodes with memory cells and incorporates a gating mechanism to address the problem of gradient vanishing in RNN. The memory cells in LSTM have the capability to either forget or remember states based on the input scale. Three memory gates, namely input, forget, and output, are utilized to provide fundamental support to the memory cell. By enabling the decoder to consult with both the final hidden layer and a specific subset of the encoder's initial input, the attention layer serves as a filter for pertinent context. A neural network that is trained to focus on significant information can better retain lengthy data sequences. This could enhance the performance of the model. The BiLSTM network takes in the input features \(A_{t}\), and produces a hidden state \(b_{c}\) for each time step. Equation for forward LSTM model:  
\[b_{c}^{for}=LSTM\big{(}A_{c},b_{c-1}^{for},d_{c-1}^{for}\big{)} \tag{18}\]  
Equation for backward LSTM model:  
\[b_{c}^{back}=LSTM\big{(}A_{c},b_{c+1}^{backward},d_{c+1}^{backward}\big{)} \tag{19}\]Bidirectional output: \[b_{c}^{BiLSTM}=\left[b_{c}^{for},b_{c}^{back}\right]\] (20) General RNN: \[b_{c}^{RNN}=RNN\Big{(}A_{c},b_{c-1}^{RNN}\Big{)}\] (21)
3. Concatenation of the models  
The mathematics behind the whole hybrid model which involves recurrent BiLSTM network and nonlinear autoregressive with exogenous inputs (NARX) must consider some more generalized RNN type. The final demand forecast is derived by taking a weighted average of predictions from the BiLSTM network and NARX model, as well as incorporating an additional general RNN term for completeness. \[M_{c}=\alpha.BiLSTM(A_{c})+\beta.RNN(A_{c})+(1-\alpha-\beta).NARX(B_{c-1},A_{c}) \tag{22}\]  
First, \(A_{c}\) represents the features extracted at \(c\), and \(BiLSTM(A_{c})\) stands for prediction by a recurrent bidirectional LSTM network. \(RNN(A_{c})\) is a generalized RNN term. \(B_{c-1}=[b_{c-1},b_{c-2},\ldots b_{c-s}]\) is a representation of the lagged values for demand. \(A_{t}=\left[a_{c-1},a_{c-2},\ldots a_{c-j}\right]\) represents the exogenous input variables. \(NARX(B_{c-1},A_{c})\) is the forecast obtained from the NARX model. \(\alpha\) and \(\beta\) are weight parameters that represent the amount of impact each model makes towards the resulting prediction. The fusion approach seeks to improve demand-forecasting accuracy and reliability by combining the strengths of the BiLSTM network, RNN component, and NARX model.