# Optimizing the Parameters of Long Short-Term Memory Networks Using the Bees Algorithm
## 4 Results and Discussion
### Two-Sample T-Test and CI: CNN-LSTM, BA-CNN-LSTM  
Two-sample T for CNN-LSTM vs BA-CNN-LSTM  
N Mean StDev SE Mean  
CNN-LSTM 600 0.0131 0.0134 0.00055  
BA-CNN-LSTM 600 0.0122 0.0116 0.00047  
Difference = u (CNN-LSTM) - u (BA-CNN-LSTM)  
Estimate for difference: 0.000871  
95% CI for difference: (-0.000545, 0.002287)  
T-Test of difference = 0.01 (vs #): T-Value = -12.65 P-Value = 0.000 DF = 1174  
\begin{table}
\begin{tabular}{c c c c c} \hline \hline  & **BA-RCNN** & **CNN-LSTM** & **BO-CNN-LSTM** & **BA-CNN-LSTM** \\ \hline Average error for percent of porosity & & & & \\ in the training data & 0.0228 & 0.0160 & 0.0166 & 0.0155 \\ \hline Average error for percent of porosity & & & & \\ in the validation data & 0.0216 & 0.0126 & 0.0128 & 0.0118 \\ \hline Average error for percent of porosity & & & & \\ in the testing data & 0.0223 & 0.0131 & 0.0131 & 0.0122 \\ \hline \hline \end{tabular}
\end{table}
Table 5: The average error for percent of porosity (artificial porosity images).  
Figure 9: The two-sample \(t\)-test between BA-RCNN, CNN-LSTM, and BA-CNN-LSTM algorithms.  
With a \(p\)-value less than 0.05, it meant that the error difference in the testing set was significant between the BA-RCNN and CNN-LSTM and between the CNN-LSTM and BA-CNN-LSTM algorithms. Thus, adding the LSTM network reduced the prediction error significantly. Furthermore, optimizing the LSTM parameters using the BA had a significant contribution as well in error reduction.  
The following Figure 10 shows the validation accuracy for all four algorithms within a 0.02 threshold (the acceptable error) using 10-fold cross-validation.  
The following Table 6 presents the training, validation, and testing average prediction accuracies of the 10-fold cross-validations for all algorithms, in addition to the time taken for computations in the best iteration.  
As can be seen from the previous table, adding the LSTM network to the CNN improved the prediction accuracy in all training, validation, and testing sets. The testing accuracy was increased by 8% in the testing set to 93.17%. Optimizing the LSTM parameters using the BO did not improve the testing accuracy, and it was almost the same with a value of 93%. The CNN-LSTM algorithm was further developed by adding the BA to optimize  
\begin{table}
\begin{tabular}{c c c c c} \hline \hline  & **BA-RCNN** & **CNN-LSTM** &
\begin{tabular}{c} **BO-CNN-** \\ **LSTM** \\ \end{tabular} & **BA-CNN-LSTM** \\ \hline Training set & 85.50\% & 88.33\% & 88.33\% & 88.33\% \\ Validation set & 87.33\% & 95.14\% & 95.07\% & 96\% \\ Testing set & 85.17\% & 93.17\% & 93\% & 95.17\% \\ Computation & 13 min 5 s & 13 min 4 s & 13 min 13 s & 12 min 49 s \\ \hline \hline \end{tabular}
\end{table}
Table 6: The prediction accuracy and time for percent of porosity (artificial porosity images).  
Figure 10: Validation accuracy for the algorithms using 10-fold cross-validation (artificial porosity images).  
the LSTM parameters, which increased the prediction accuracy in the validation and testing sets from 95.14% and 93.17% to 96% and 95.17%, respectively, so the improvement in the testing set was 2% from the CNN-LSTM algorithm and 10% from the BA-RCNN algorithm. The improvement was similar to the improvement discussed in Section 2.3, as the hybrid ABC-CNN-LSTM algorithm used to detect fake reviews of a product yielded an accuracy of 97% compared to 95% for the CNN-LSTM algorithm [29]. The computational time was almost similar for all algorithms.  
As a result, the performance of the LSTM network for predicting sequential data was improved after using the BA, as the hybrid BA-CNN-LSTM provided a more accurate prediction by 10% for the percent of porosity in sequential layers of artificial porosity images that mimicked CT scan images of parts manufactured by the SLM process.