# Container Volume Prediction Using Time-Series Decomposition with a Long Short-Term Memory Models
## 3 Method
### Time-Series Decomposition with LSTM Model
For external variables, the decomposed values are prepared and thus, the trend decomposed of the \(m\)th external variable can be expressed as Equation (7). The seasonality and residuals of external variables are given in Equations (8) and (9). \[\mathbf{Tv}=\left[ \begin{array}{cccc}\textit{Tv}_{11}&\textit{Tv}_{12}&\ldots &\textit{Tv}_{1m}\\ \vdots&\vdots&\vdots&\vdots\\ \textit{Tv}_{n1}&\textit{Tv}_{n2}&\ldots&\textit{Tv}_{nm}\end{array} \right] \tag{7}\]  
\[\mathbf{Sv}=\left[ \begin{array}{cccc}\textit{Sv}_{11}&\textit{Sv}_{12}&\ldots &\textit{Sv}_{1m}\\ \vdots&\vdots&\vdots&\vdots\\ \textit{Sv}_{n1}&\textit{Sv}_{n2}&\ldots&\textit{Sv}_{nm}\end{array} \right] \tag{8}\]  
\[\mathbf{Rv}=\left[ \begin{array}{cccc}\textit{Rv}_{11}&\textit{Rv}_{12}&\ldots &\textit{Rv}_{1m}\\ \vdots&\vdots&\vdots&\vdots\\ \textit{Rv}_{n1}&\textit{Rv}_{n2}&\ldots&\textit{Rv}_{nm}\end{array} \right] \tag{9}\]  
Equations (7)-(9) show the expressions that represent a combination of five external variables with container volume time-series components. To derive the input matrices, we first combine _Trend_\(\mathbf{Tr}\) with the external variables' trend component _Tv_ expressed in Equation (10). The elements in the first column of the combined matrix are the trend values of the container volume; the other columns are those of the external variables. Therefore, the number of columns in the matrix is \(m\), where \(m\) is the number of external variables. Combined matrices for seasonality and residuals are computed that denote each component input as _TI_, _SI_, and _RI_, respectively. \[\mathbf{TI}=\mathbf{Tr}^{T}+\mathbf{Tv}=\left[ \begin{array}{cccc}\textit{Tr}_{1}&\textit {Tv}_{11}&\textit{Tv}_{12}&\ldots&\textit{Tv}_{1m}\\ \vdots&\vdots&\vdots&\vdots&\vdots\\ \textit{Tr}_{n}&\textit{Tv}_{n1}&\textit{Tv}_{n2}&\ldots&\textit{Tv}_{nm} \end{array} \right] \tag{10}\]  
\[\mathbf{SI}=\mathbf{Sn^{T}}+\mathbf{Sv}=\left[ \begin{array}{cccc}\textit{Sn}_{1}& \textit{Sv}_{11}&\textit{Sv}_{12}&\ldots&\textit{Sv}_{1m}\\ \vdots&\vdots&\vdots&\vdots&\vdots\\ \textit{Sn}_{n}&\textit{Sv}_{n1}&\textit{Sv}_{n2}&\ldots&\textit{Sv}_{nm} \end{array} \right] \tag{11}\]  
\[\mathbf{RI}=\mathbf{Rd^{T}}+\mathbf{Rv}=\left[ \begin{array}{cccc}\textit{Rd}_{1}&\textit {Rv}_{11}&\textit{Rv}_{12}&\ldots&\textit{Rv}_{1m}\\ \vdots&\vdots&\vdots&\vdots&\vdots\\ \textit{Rd}_{n}&\textit{Rv}_{n1}&\textit{Rv}_{n2}&\ldots&\textit{Rv}_{nm} \end{array} \right] \tag{12}\]  
In this study, we considered 12 months (\(n=12\)) as the input for the prediction of six months. Finally, Equations (13)-(15) are used to derive the predictive values of the elements based on different multivariate LSTM models. The layers that constitute the LSTM model are constructed differently because the multivariate LSTM model exhibits different layers that are optimized according to trend, seasonality, and residual information. The output of the trend is also expressed as a vector with \(t\) elements where \(t\) is the length of the output periods. \[\mathbf{TO} =LSTM_{1}\ (\mathbf{TI}) \tag{13}\] \[\mathbf{SO} =LSTM_{2}(\mathbf{SI})\] (14) \[\mathbf{RO} =LSTM_{3}\ (\mathbf{RI}) \tag{15}\]  
The output list of predicted values (\(\mathbf{PV}\)) as the final volume prediction can be obtained from the derived trends, seasonality, and residuals as shown in Equation (16). \[\mathbf{PV}=\mathbf{TO}+\mathbf{SO}+\mathbf{RO} \tag{16}\]  
Figure 7 represents the neural network architecture of time-series decomposition with the LSTM model for the proposed method. Figure 7: Long short-term memory architecture for time-series decomposition. To assess the performance of the proposed model and compare it with other methods, MAE and root mean squared error (RMSE), which are denoted in Equations (17) and (18), are used. \[MAPE=\frac{100\%}{n}\sum_{t=1}^{n}\left|\frac{Actual_{t}-Predicted_{t}}{Actual_{t}}\right| \tag{17}\]  
\[RMSE=\sqrt{\frac{\sum_{i=1}^{n}(Predicted_{t}-Actual_{t})^{2}}{n}} \tag{18}\]