A Satoła, K Satoła
Subclinical mastitis, one of the most common disorders in dairy cattle farming, affects both milk yield and milk quality. While it causes no visible changes to the udder or milk, it may be either chronic or progress to clinical mastitis. This increases the costs of milk production and herd management, and it is therefore important to devise a means of early identification of cows at risk of subclinical mastitis. The aim of the study was to develop and evaluate models based on artificial neural networks and designed for the identification of cows at risk of subclinical mastitis. Neural networks can recognize complex data patterns; however, the process of building a model, selecting hyperparameters and training a network is a time-consuming and computationally intensive task, and therefore neural network-based models were compared with classical machine learning (ML) models: Support Vector Machines (SVM), Random Forest and Gradient Boosting. The data were collected between 2010 and 2011 as part of routine milk recording procedures. The data set contained 19,768 test day records for 2,225 Polish Holstein-Friesian cows from 3 herds. All the models were trained and evaluated using an 80:20 train-test split ratio according to animal ID. Cows were classified as healthy or at risk of subclinical mastitis based on data from the test day preceding the test day for which the prediction was made. The neural network that achieved the highest mean F1-score in the cross validation (0.763) and for the testing data set (0.760) was optimized using the BayesianOptimization tuner, and the data were rescaled using RobustScaler before calculations. However, the mean F1-scores from the cross validation for 3 classical ML models: SVM, Random Forest and Gradient Boosting, were higher (0.769, 0.769 and 0.766 respectively) than the F1-score obtained for the best performing neural network. SVM and Random Forest models also achieved higher F1-scores (0.763 and 0.761 respectively) for the testing data set as compared with the best performing neural network. As far as ML models are concerned, an increasing importance is also being placed on the interpretation and evaluation of the impact of individual variables on model-derived predictions. This is where SHAP (SHapley Additive exPlanations) values can become useful. For the best performing classical ML models: SVM, Random Forest and Gradient Boosting, and the best performing neural network, somatic cell score (SCS) from previous test day had the greatest impact on predictions, and a higher SCS was associated with a greater probability of subclinical mastitis occurring in subsequent test day. The second variable with the greatest impact on the risk of subclinical mastitis was lactation number. Depending on the model, the third most influential variable was milk yield, lactose percentage or fat percentage. Classical ML models with good predictive performance can support farmers in making decisions concerning the health of cows' udders, and the use of model interpretation tools can help understand why a particular model generates a particular prediction.