CIEL | Case Study: Machine learning to improve the diagnosis of mastitis infections in cows 

Genetics | Reproduction | Behaviour | Nutrition | Health & Welfare | Productivity | Food Integrity | Environmental Impact


Mastitis in dairy cattle is extremely costly both in economic and welfare terms and is one of the most significant drivers of antimicrobial usage in dairy cattle. A crucial first step in the diagnosis of mastitis infections and their control is identifying the route of infection as “contagious” or “environmental”. Contagious bacteria commonly exist within the animal’s mammary gland and are transmitted between cows during milking. Environmental bacteria do not generally survive in the host animal, rather they are opportunistic invaders from the cow’s environment. Diagnosis is usually performed by a vet by analysing data from the dairy farm and is costly in terms of time and specialist veterinary training.


A study by the School of Veterinary Medicine and Science at the University of Nottingham has found that machine learning has the potential to enhance and improve a vet’s ability to accurately diagnose herd mastitis origin and reduce mastitis levels on dairy farms. Machine learning algorithms are widely used in day-today life, from the filtering of spam emails to entertainment streaming services suggesting new films to watch based on viewer preference. They are also being applied within the clinical environment, and in some instances within the field of farm animal medicine. These algorithms approach diagnostic problems as a veterinarian or doctor might, learning rules from data and applying them to new ‘patients’.

Nottingham’s research aims to create an automated diagnostic support tool for the diagnosis of herd-level mastitis origin. Using mastitis data collected from 1,000 herds, machine learning algorithms were used to classify herd mastitis origin and compared with expert diagnosis by a specialist vet. The machine learning algorithms were able to achieve a classification accuracy of 98% for environmental vs contagious mastitis, and 78% accuracy was achieved for the classification of lactation vs dry period environmental mastitis when compared with expert veterinary diagnosis.


The research offers crucial evidence that machine learning algorithms can accurately diagnose the origin of mastitis on dairy farms. This will help ensure prompt implementation of control measures for an extremely damaging disease in terms of animal health, productivity, welfare and antimicrobial use.

Auto Milker | CDSI