An interpretable stacking model for early warning of mastitis in dairy cows.

Journal: Preventive veterinary medicine
Published Date:

Abstract

Early warning of mastitis in dairy cows is important for maintaining animal health and improving dairy production. However, existing early warning systems often rely on single models, which may limit predictive performance. Therefore, this study developed a stacking prediction model for mastitis in dairy cows. A balanced dataset was constructed using random under-sampling, and features were selected through correlation analysis and their physiological relevance to mastitis. Based on the selected features, the hyperparameters of nine commonly used binary classification machine learning models were optimized using a grid search strategy, and the final base learners were determined through an exhaustive combination search that considered both predictive performance and model complexity. The results showed that the stacking model achieved good predictive performance on the test set, with an AUC of 0.9318 (95% CI: 0.9148-0.9468), an F1-score of 0.8547 (95% CI: 0.8250-0.8796), an accuracy of 0.8557 (95% CI: 0.8300-0.8790), and a recall of 0.8484 (95% CI: 0.8125-0.8840), outperforming the individual base learners. In addition, SHAP was introduced to improve model interpretability. SHAP analysis identified key influential features, including milk yield in the first 2 min and electrical conductivity, quantified the direction and magnitude of their contributions to mastitis prediction, and provided insight into how the model made predictions. Overall, this method improved predictive performance while enhancing model transparency, and it may provide support for mastitis early warning and management decisions on dairy farms.

Authors

Keywords

No keywords available for this article.