Optimized machine learning-collaborative filtering model for mastitis prediction in dairy cows

Authors

  • Wu Jingzhu 1. Beijing Key Laboratory of Big Data Technology for Food Safety, Beijing Technology and Business University, Beijing 100048, China https://orcid.org/0000-0002-8386-1038
  • Liu Yutong 1. Beijing Key Laboratory of Big Data Technology for Food Safety, Beijing Technology and Business University, Beijing 100048, China
  • Zheng Yongjun 2. College of Engineering, China Agricultural University, Beijing 100083, China;3. State Key Laboratory of Veterinary Public Health and Safety, Beijing 100193, China;
  • Yuan Xiyan 1. Beijing Key Laboratory of Big Data Technology for Food Safety, Beijing Technology and Business University, Beijing 100048, China;
  • Wang Haoyu 2. College of Engineering, China Agricultural University, Beijing 100083, China;
  • Yang Shenghui 2. College of Engineering, China Agricultural University, Beijing 100083, China;
  • Guan Ning 4. National Technology Innovation Center for Dairy, Hohhot 010110, China;5. Inner Mongolia Yili Industrial Group Co. Ltd., Hohhot 010110, China;
  • Pei Xiaoyan 4. National Technology Innovation Center for Dairy, Hohhot 010110, China;5. Inner Mongolia Yili Industrial Group Co. Ltd., Hohhot 010110, China;
  • Li Shu 6. Optimization of Inner Mongolia Animal Husbandry Co. Ltd., Hohhot 010000, China;
  • Wu Congming 7. College of Veterinary Medicine, China Agricultural University, Beijing 100193, China

Keywords:

mastitis prediction, machine learning, feature selection, XGBoost, collaborative filtering

Abstract

Mastitis is a major disease affecting dairy cow health and milk production. This study established an integrated machine learning (ML) model combining herd- and individual-level data to achieve efficient and balanced prediction of clinical mastitis. Data were collected from 5284 lactating Holstein cows on two farms in southern and northern China. Five feature processing methods—recursive feature elimination (RFE), contrastive learning (CL), slopes and intercept, milk-conductivity ratio, and differences—were evaluated with four ML algorithms: Support vector machine (SVM), random forest (RF), XGBoost, and backpropagation neural network (BPNN). Among them, the XGBoost model with the milk-conductivity ratio feature achieved the best performance, with a sensitivity of 0.81 and specificity of 0.75. To further address the imbalance between sensitivity and specificity, collaborative filtering (CF) was introduced into the XGBoost model to incorporate both herd and individual cow information. The resulting XGBoost–CF model improved sensitivity to 0.83 and specificity to 0.87, enhancing the model’s ability to identify both healthy and diseased cows. This integrated ML–CF framework provides an effective strategy for early mastitis prediction, offering practical support for intelligent dairy herd management and precision livestock farming.

Keywords: mastitis prediction, machine learning, feature selection, XGBoost, collaborative filtering

DOI: 10.25165/j.ijabe.20261901.10304

Citation: Wu J Z, Liu Y T, Zheng Y J, Yuan X Y, Wang H Y, Yang S H, et al. Optimized machine learning-collaborative filtering model for mastitis prediction in dairy cows. Int J Agric & Biol Eng, 2026; 19(1): 21–25.

 

Author Biographies

Wu Jingzhu, 1. Beijing Key Laboratory of Big Data Technology for Food Safety, Beijing Technology and Business University, Beijing 100048, China

Beijing Key Laboratory of Big Data Technology for Food Safety,Professor

Liu Yutong, 1. Beijing Key Laboratory of Big Data Technology for Food Safety, Beijing Technology and Business University, Beijing 100048, China

School of Computer and Artificial Intelligence,Graduate Student

Zheng Yongjun, 2. College of Engineering, China Agricultural University, Beijing 100083, China;3. State Key Laboratory of Veterinary Public Health and Safety, Beijing 100193, China;

College of Engineering,Professor

Yuan Xiyan, 1. Beijing Key Laboratory of Big Data Technology for Food Safety, Beijing Technology and Business University, Beijing 100048, China;

School of Computer and Artificial Intelligence,Graduate Student

Wang Haoyu, 2. College of Engineering, China Agricultural University, Beijing 100083, China;

College of Engineering,Postdoctoral Fellow

Yang Shenghui, 2. College of Engineering, China Agricultural University, Beijing 100083, China;

College of Engineering,Professor

Guan Ning, 4. National Technology Innovation Center for Dairy, Hohhot 010110, China;5. Inner Mongolia Yili Industrial Group Co. Ltd., Hohhot 010110, China;

Inner Mongolia Yili Industrial Group Co. Ltd,Engineer

Pei Xiaoyan, 4. National Technology Innovation Center for Dairy, Hohhot 010110, China;5. Inner Mongolia Yili Industrial Group Co. Ltd., Hohhot 010110, China;

Inner Mongolia Yili Industrial Group Co. Ltd,Engineer

Wu Congming, 7. College of Veterinary Medicine, China Agricultural University, Beijing 100193, China

College of Veterinary Medicine,Professor

References

[1] Chu M Y, Liu X W, Zeng X T, Wang Y C, Liu G. Research advances in the automatic detection technology for mastitis of dairy cows. Trans. Chin. Soc. Agric. Eng., 2023; 39(11): 1–12. (in Chinese)

[2] Chen L J. Cow mastitis and scientific prevention and control measures. China Anim. Health, 2023; 25: 40–41. (in Chinese)

[3] Ma R J, Du L, Ma W D, Zhao J H, Li Q C, Lei C Z, et al. Study on the general situation and prevention and control measures of subclinical mastitis. China Cattle Sci., 2023; 49(4): 47–50. (in Chinese)

[4] Ye W, Ma Z, Yu Y, Han B. Incidence status of mastitis in dairy cows and its prevention and treatment measures in China. Chin. J. Anim. Sci., 2023; 59(9): 343–348. (in Chinese)

[5] Wang A H, Yang L F. Causes, clinical symptoms, diagnosis and treatment of cow mastitis. Mod. Anim. Husb. Sci. Technol., 2023(10): 94–96. (in Chinese)

[6] Zhang Y, Shi Q, Zhou Q M, Feng W Y, Xu X, Wu X. Isolation, identification, drug sensitivity and pathogenicity of pathogenic bacteria in dairy cow mastitis. Heilongjiang Anim. Sci. Vet. Med., 2020; (23): 85–88, 167–168. (in Chinese)

[7] Liebe D M, Steele N M, Petersson-Wolfe C S, De Vries A, White R R. Practical challenges and potential approaches to predicting low-incidence diseases on farm using individual cow data: A clinical mastitis example. J. Dairy Sci., 2022; 105(3): 2369–2379.

[8] Naqvi S A, King M T M, Matson R D, Devries T J, Deardon R, Barkema H W. Mastitis detection with recurrent neural networks in farms using automated milking systems. Comput. Electron. Agric., 2022; 192: 106618.

[9] Tian H, Zhou X J, Wang H, Xu C, Zhao Z X, Xu W, et al. The prediction of clinical mastitis in dairy cows based on milk yield, rumination time, and milk electrical conductivity using machine learning algorithms. Animals, 2024; 14(3): 427.

[10] Satola A, Satola K. Performance comparison of machine learning models used for predicting subclinical mastitis in dairy cows: bagging, boosting, stacking, and super-learner ensembles versus single machine learning models. J. Dairy Sci., 2024; 107(6): 3959–3972.

[11] Pakrashi A, Ryan C, Guéret C, Berry D P, Corcoran M, Keane M T, et al. Early detection of subclinical mastitis in lactating dairy cows using cow-level features. J. Dairy Sci., 2023; 106(7): 4978–4990.

[12] Luo W K, Dong Q, Feng Y. Risk prediction model of clinical mastitis in lactating dairy cows based on machine learning algorithms. Prev. Vet. Med., 2023; 221: 106059.

[13] Ebrahimi M, Mohammadi-Dehcheshmeh M, Ebrahimie E, Petrovski K R. Comprehensive analysis of machine learning models for prediction of sub-clinical mastitis: Deep learning and gradient-boosted trees outperform other models. Comput. Biol. Med., 2019; 114: 103456.

[14] Shi Y L, Li W L, Tang Y J, Mi S Y, Xiao W, Liu L, et al. Studies on risk-assessment-model establishment and prediction of mastitis in Chinese Holstein cattle. Chin. J. Anim. Sci., 2021; 57(3): 84–90. (in Chinese)

[15] Li W L, Zhao T T, Da R, Shi Y L, Guo G, Wang Y C, et al. Application and optimization of dairy cow mastitis risk assessment system in Chinese Holstein. Chin. J. Anim. Sci., 2021; 57(10): 65–72.

[16] Bobbo T, Biffani S, Taccioli C, Penasa M, Cassandro M. Comparison of machine learning methods to predict udder health status based on somatic cell counts in dairy cows. Sci. Rep., 2021; 11: 13642.

[17] Ozella L, Brotto R K, Forte C, Giacobini M. A literature review of modeling approaches applied to data collected in automatic milking systems. Animals, 2023; 13(12): 1916.

[18] Zhou X J, Xu C, Wang H, Xu W, Zhao Z X, Chen M X, et al. The early prediction of common disorders in dairy cows monitored by automatic systems with machine learning algorithms. Animals, 2022; 12(10): 1251.

[19] Zhou X Z, Wen H J, Zhang Y L, Xu J H, Zhang W G. Landslide susceptibility mapping using hybrid random forest with Geo Detector and RFE for factor optimization. Geosci. Front., 2021; 12(5): 101211.

[20] Zhang C S, Chen J, Li Q L, Deng B Q, Wang J, Chen C G. Deep contrastive learning: A survey. Acta Autom. Sin., 2023; 49(1): 15–39.

[21] Sun Y, Zhou G Y, Wu T B, Li Y L, Ji S Q, Zhang T. Recent research progress of cow mastitis in China. China Dairy, 2022(4): 43–51. (in Chinese)

[22] Zhai Y, Zhou B, Zhou F Z, Dai X, Liang Y, Zhang H R, et al. Analysis of factors affecting milk yield, conductivity, and activity level in Holstein cows. Chin. J. Anim. Sci., 2024; 60(6): 148–153. (in Chinese)

[23] Fan X, Watters R D, Nydam D V, Virkler P D, Wieland M, Reed K F. Multivariable time series classification for clinical mastitis detection and prediction in automated milking systems. J. Dairy Sci., 2023; 106(5): 3448–3464.

[24] Bonestroo J, van der Voort M, Hogeveen H, Emanuelson U, Klaas I C, Fall N. Forecasting chronic mastitis using automatic milking system sensor data and gradient-boosting classifiers. Comput. Electron. Agric., 2022; 198: 107002.

Downloads

Published

2026-03-16

How to Cite

(1)
Jingzhu, W.; Yutong, L.; Yongjun, Z.; Xiyan, Y.; Haoyu, W.; Shenghui, Y.; Ning, G.; Xiaoyan, P.; Shu, L.; Congming, W. Optimized Machine Learning-Collaborative Filtering Model for Mastitis Prediction in Dairy Cows. Int J Agric & Biol Eng 2026, 19.

Issue

Section

Animal, Plant and Facility Systems