Introduction
Mastitis, a prevalent and costly disease in dairy farming, significantly impacts milk production and quality. Early and accurate prediction of mastitis is crucial for effective herd management and minimizing economic losses. This study investigated the effects of farm-specific factors on the accuracy of mastitis predictions by applying machine learning (ML) models to AMS data.
Methods
We collected and analyzed a large dataset consisting of 2.73 million observations over the period of 2019–2022, from two dairy farms in Germany. Six ML algorithms, i.e., Logistic Regression, Support Vector Machines, Decision Tree, Random Forest, Multi-Layer Perceptron Neural Networks and Gradient Boosting Decision Tree, were applied to predict mastitis occurrence, with a focus on understanding how farm-specific factors like herd size, management practices, and farm environment influence prediction accuracy.
Results
For training and testing on both farms combined, the accuracy, sensitivity and specificity were estimated at 0.89–0.93, 0.79–0.92 and 0.89–0.93, respectively. When training and testing both individual farms separately, the accuracy, sensitivity and specificity estimates were (i) 0.85–0.93, 0.73–0.91 and 0.85–0.93 for the large farm, and (ii) 0.89–0.96, 0.63–0.89 and 0.89–0.96 for the small farm, respectively. However, after training the models on the combined dataset over a period of three years (2019–2021) and testing on each farm individually for year 2022, the accuracy, sensitivity and specificity estimates were (i) 0.78-0.94, 0.85–0.98 and 0.78–0.94 (large farm), and (ii) 0.92–0.98, 0.70–0.96 and 0.92–0.98 (small farm), respectively. The analysis determined that sensitivity scores for the large farm and accuracy, sensitivity and specificity scores for the small farm improved significantly by training models on combined data but testing each farm separately.
Conclusion
Our findings suggest that training ML models on a combined database and testing with an approach tailored to each farm’s unique characteristics seem to be a feasible approach to improve mastitis prediction.