# Leveraging IGOOSE-XGBoost for the Early Detection of Subclinical Mastitis in Dairy Cows
## 5 Prediction Model for Subclinical Mastitis in Dairy Cows Based on IGOOSE-XGboost
### Building the IGOOSE-XGBoost Regression Model for Subclinical mastitis in Dairy Cows
#### 5.3.3 Building the IGOOSE-XGBoost Regression Model  
First, four commonly used machine learning methods, KNN [34], XGBoost, SVM [35], and GBDT [36], were used to perform regression prediction. According to the correlation analysis, each sample contained four features. The comparison of the evaluation metrics of several regression models is displayed in Table 6. From the evaluation results, the XGBoost model shows optimal prediction performance, with the highest coefficient of determination (R2 = 0.631 \(\pm\) 0.013) and the lowest mean absolute error (MAE = 0.552 \(\pm\) 0.016) and mean square error (MSE = 0.565 \(\pm\) 0.017). This is followed by the GBDT model, which performs slightly better than XGBoost in terms of root mean square error (RMSE = 0.753 \(\pm\) 0.020) but is slightly inferior in terms of other metrics such as R2 value (0.611 \(\pm\) 0.015) and MAE (0.565 \(\pm\) 0.021). The KNN model has the worst overall performance, with the lowest R2 value (0.485 \(\pm\) 0.018) and all its error metricsbeing significantly higher than the other models. All the models maintain strong stability (standard deviation \(\leq\) 0.026), according to the standard deviation study, with the XGBoost model having the best stability (standard deviation range 0.013-0.018). The best prediction results are shown by the XGBoost model when all four evaluation measures are compared. The relevant literature indicates that swarm intelligence optimization techniques are increasingly being used to optimize model search procedures. SSA [37], WOA [38], ESOA [39], GOOSE, and IGOSOSE were combined with XGBoost, as shown in Figure 5. Five combined models were obtained by adding an optimization process, and the obtained prediction results were compared and analyzed to find a new model with optimal performance. The comparison findings of these optimized models' assessment standards are displayed in Table 7. As can be seen from the data, the IGOOSE-XGBoost model achieves the best performance in all the metrics: it has the highest R\({}^{2}\) value (0.663 \(\pm\) 0.012), and the lowest MAE (0.526 \(\pm\) 0.013), MSE (0.511 \(\pm\) 0.014), and RMSE (0.693 \(\pm\) 0.015). The GOOSE-XGBoost model performs second best, with a similar R\({}^{2}\) value (0.642 \(\pm\) 0.013) and error metrics (MAE = 0.531 \(\pm\) 0.014, MSE = 0.521 \(\pm\) 0.015, and RMSE = 0.722 \(\pm\) 0.016) to IGOSE-XGBoost. The other optimized models, although improved compared to the base model, are not as significantly improved as the IGOOSE and GOOSE models. It is particularly noteworthy that in comparison with the original XGBoost model, the IGOOSE-optimized model achieves significant improvements in all evaluation metrics: the R\({}^{2}\) value improves by 0.032 (from 0.631 to 0.663), the MAE decreases by 0.026 (from 0.552 to 0.526), the MSE decreases by 0.054 (from 0.565 to 0.511), and the RMSE decreases by 0.065 (from 0.758 to 0.693). These improvements are not only statistically significant (\(p\) < 0.05), but also valuable in practical applications. Furthermore, all the optimized models' assessment metrics' standard deviations are maintained at a low level (\(\leq\)0.015), demonstrating the \begin{table}
\begin{tabular}{l c c c c} \hline
**Evaluation Indicators** & **SVR** & **GBDT** & **KNN** & **XGBoost** \\ \hline Average R\({}^{2}\) & 0.578 \(\pm\) 0.016 & 0.611 \(\pm\) 0.015 & 0.485 \(\pm\) 0.018 & 0.631 \(\pm\) 0.13 \\ Average MAE & 0.646 \(\pm\) 0.021 & 0.565 \(\pm\) 0.021 & 0.727 \(\pm\) 0.023 & 0.552 \(\pm\) 0.016 \\ Average MSE & 0.753 \(\pm\) 0.024 & 0.571 \(\pm\) 0.019 & 0.934 \(\pm\) 0.026 & 0.565 \(\pm\) 0.017 \\ Average RMSE & 0.868 \(\pm\) 0.022 & 0.753 \(\pm\) 0.020 & 0.967 \(\pm\) 0.024 & 0.758 \(\pm\) 0.018 \\ \hline \end{tabular}
\end{table} 
Table 6: Comparison of evaluation indicators of different regression models.