Skip to main content
SLU publication database (SLUpub)

Research article2021Peer reviewedOpen access

Detecting and predicting changes in milk homogeneity using data from automatic milking systems

Anglart, D.; Emanuelson, U.; Ronnegard, L.; Sandgren, C. Hallen


To ensure milk quality and detect cows with signs of mastitis, visual inspection of milk by prestripping quarters before milking is recommended in many countries. An objective method to find milk changed in homogeneity (i.e., with clots) is to use commercially available inline filters to inspect the milk. Due to the required manual labor, this method is not applicable in automatic milking systems (AMS). We investigated the possibility of detecting and predicting changes in milk homogeneity using data generated by AMS. In total, 21,335 quarter-level milk inspections were performed on 5,424 milkings of 624 unique cows on 4 farms by applying visual inspection of inline filters that assembled clots from the separate quarters during milking. Images of the filters with clots were scored for density, resulting in 892 observations with signs of clots for analysis (77% traces or mild cases, 15% moderate cases, and 8% heavy cases). The quarter density scores were combined into 1 score indicating the presence of clots during a single cow milking and into 2 scores summarizing the density scores in cow milkings during a 30-h sampling period. Data generated from the AMS, such as milk yield, milk flow, conductivity, and online somatic cell counts, were used as input to 4 multilayer perceptron models to detect or predict single milkings with clots and to detect milking periods with clots. All models resulted in high specificity (98-100%), showing that the models correctly classified cow milkings or cow milking periods with no clots observed. The ability to successfully classify cow milkings or cow periods with observed clots had a low sensitivity. The highest sensitivity (26%) was obtained by the model that detected clots in a single milking. The prevalence of clots in the data was low (2.4%), which was reflected in the results. The positive predictive value depends on the prevalence and was relatively high, with the highest positive predictive value (72%) reached in the model that detected clots during the 30-h sampling periods. The misclassification rate for cow milkings that included higher-density scores was lower, indicating that the models that detected or predicted clots in a single milking could better distinguish the heavier cases of clots. Using data from AMS to detect and predict changes in milk homogeneity seems to be possible, although the prediction performance for the definitions of clots used in this study was poor.


dairy cow; clinical mastitis; clot; multilayer perception

Published in

Journal of Dairy Science
2021, Volume: 104, number: 10, pages: 11009-11017