# Prediction of Cotton Yarn Quality Based on Attention-GRU
## 3 Case Analysis
### Model Testing and Comparison
This can be attributed to the attention-GRU cotton quality prediction model's capability to seamlessly incorporate temporal correlations between preceding and subsequent production processes. By simultaneously considering cotton indicator parameters and process production data, the model aligns more effectively with the actual production processes. The incorporation of the attention mechanism further enhances the model's ability to select and optimize driving parameters, leading to a notable reduction in prediction errors. The aforementioned analysis indicates that the application of the proposed attention-GRU model maintains a leading position in the context of yarn quality prediction. It demonstrates the lowest fit loss value on the training dataset. Moreover, by implementing an adaptive loss change threshold, the training time of the model has been reduced, further enhancing the predictive efficiency of the model. Additionally, during the quantitative evaluation of predictive results on the test dataset, the proposed attention-GRU model showcases the lowest predictive loss value. This emphasizes that the model's predic  
Figure 10: Comparative analysis of model prediction accuracy and performance: (**a**) predicted results curves of each model; (**b**) comparative performance of predictive models. \begin{table}
\begin{tabular}{c c c c c c c c c} \hline \hline \multirow{2}{*}{**Test Sample No.**} & \multirow{2}{*}{**Actual Value**} & \multicolumn{2}{c}{**BP**} & \multicolumn{2}{c}{**LSTM**} & \multicolumn{2}{c}{**GRU**} & \multicolumn{2}{c}{**Attention-GRU**} \\ \cline{3-10}  & & **Prediction** & **Error** & **Prediction** & **Error** & **Prediction** & **Error** & **Prediction** & **Error** \\ \hline
1 & 16.21 & 16.33 & 0.12 & 16.22 & 0.01 & 16.15 & 0.06 & 16.18 & 0.03 \\
2 & 16.28 & 16.52 & 0.24 & 16.43 & 0.15 & 16.44 & 0.16 & 16.19 & 0.09 \\
3 & 16.57 & 16.71 & 0.14 & 16.42 & 0.15 & 16.45 & 0.12 & 16.61 & 0.04 \\
4 & 16.59 & 16.66 & 0.07 & 16.72 & 0.13 & 16.57 & 0.02 & 16.66 & 0.07 \\
5 & 16.11 & 16.18 & 0.07 & 16.10 & 0.01 & 16.10 & 0.01 & 16.14 & 0.03 \\
6 & 16.37 & 16.37 & 0.00 & 16.37 & 0.00 & 16.27 & 0.10 & 16.38 & 0.01 \\
7 & 16.53 & 16.75 & 0.22 & 16.56 & 0.03 & 16.43 & 0.10 & 16.63 & 0.10 \\
8 & 16.52 & 16.60 & 0.08 & 16.47 & 0.05 & 16.60 & 0.08 & 16.49 & 0.03 \\
9 & 16.78 & 16.84 & 0.06 & 16.87 & 0.09 & 16.84 & 0.06 & 16.72 & 0.06 \\
10 & 16.13 & 16.19 & 0.06 & 16.23 & 0.10 & 16.19 & 0.06 & 16.13 & 0.00 \\ \hline \hline \multicolumn{1}{c}{\(E_{mse}\)} & \multicolumn{2}{c}{0.128} & \multicolumn{2}{c}{0.091} & \multicolumn{2}{c}{0.088} & \multicolumn{2}{c}{0.056} \\ \multicolumn{1}{c}{\(E_{mse}/\%\)} & \multicolumn{2}{c}{0.646} & \multicolumn{2}{c}{0.437} & \multicolumn{2}{c}{0.469} & \multicolumn{2}{c}{0.279} \\ \multicolumn{1}{c}{\(R^{2}\)} & \multicolumn{2}{c}{0.636} & \multicolumn{2}{c}{0.814} & \multicolumn{2}{c}{0.827} & \multicolumn{2}{c}{0.931} \\ \hline \hline \end{tabular}
\end{table} 
Table 5: Comparison of model prediction results. tions closely approximate the actual values of yarn tensile strength, demonstrating its strong generalization ability and effectiveness in the context of yarn quality prediction applications.