# Machine Learning-Based Lithium Battery State of Health Prediction Research
## 4 Experimentation and Analysis of Results
### Model Experiment Results
#### 4.2.3 Analysis of the Effects Before and After Model Optimization  
When the PSO algorithm is not used for optimization, the model parameters are set to default values for model building, training, and prediction. Figure 6 presents a comparison between the predicted and actual values for the same dataset before and after optimization for the three models.  
\begin{table}
\begin{tabular}{c c c c c c} \hline \hline
**Dataset** & **Prediction Model** & **MAE** & **RMSE** & **MAPE** & \(\text{R}^{2}\) \\ \hline \multirow{3}{*}{B0005} & PSO-LSTM & 0.007413 & 0.010931 & 0.545550 & 0.921261 \\  & PSO-CNN & 0.010617 & 0.015898 & 0.930365 & 0.865900 \\  & PSO-SVR & 0.013960 & 0.015080 & 1.040813 & 0.845538 \\ \hline \multirow{3}{*}{B0006} & PSO-LSTM & 0.012182 & 0.015197 & 0.961381 & 0.907357 \\  & PSO-CNN & 0.016638 & 0.018703 & 1.457222 & 0.833906 \\  & PSO-SVR & 0.018802 & 0.020316 & 1.835633 & 0.827241 \\ \hline \multirow{3}{*}{B0007} & PSO-LSTM & 0.006739 & 0.009433 & 0.458213 & 0.929801 \\  & PSO-CNN & 0.009785 & 0.013172 & 0.899458 & 0.879730 \\ \cline{1-1}  & PSO-SVR & 0.012121 & 0.014075 & 1.569721 & 0.839245 \\ \hline \hline \end{tabular}
\end{table}
Table 7: Prediction errors of the dataset on different models.  
As shown in Figure 6, after optimization by the PSO algorithm, the three models exhibit a significant improvement in prediction accuracy for all three datasets. Compared to the unoptimized models, the optimized prediction curves are closer to the actual values, with smaller fluctuations, demonstrating higher accuracy and stability. This optimization effectively reduces errors and improves the model's fit to the actual values, verifying the effectiveness of the optimization strategy. Furthermore, a horizontal comparison of Figure 6 reveals that in subfigures (a) to (c), the purple curve (representing the unoptimized LSTM predictions) in subfigure (a) is closer to the blue curve (the actual values of battery B0005), indicating that the LSTM model outperforms the other two models even before optimization. Similar conclusions can be drawn from the prediction results of battery B0006 in subfigures (d) to (f) and battery B0007 in subfigures (g) to (i).  
Figure 6: Comparison of the prediction results before and after model optimization on the same dataset. Among them, (**a–c**) represent the comparison between the predicted values and the actual values of the B0005 dataset before and after the optimization of the three models, respectively. (**d–f**) represent the comparison between the predicted values and the actual values of the B0006 dataset before and after the optimization of the three models, respectively. (**g–i**) represent the comparison between the predicted values and the actual values of the B0007 dataset before and after the optimization of the three models, respectively.  
A comparison of the model performance evaluation metrics before and after optimization is presented in Table 8. The table shows that after optimization by the PSO algorithm, the error metrics for all three models improved significantly, with a notable decrease in MAE, MAPE, and RMSE, and an increase in R\({}^{2}\). The reduction in MAE and RMSE indicates enhanced prediction accuracy and precision, while the significant decrease in MAPE confirms increased reliability in predicting different capacity ranges. The increase in R\({}^{2}\) reflects improvements in the model's fitting ability, stability, and generalization. Furthermore, a comparison of the results before optimization reveals that the LSTM model outperforms the CNN and SVR models, achieving the smallest RMSE, MAE, and MAPE values, along with the highest R\({}^{2}\), which exceeds 0.8. This highlights its superior predictive capability and validates the earlier conclusion that, prior to optimization, the LSTM model demonstrated the best predictive performance among the three models.