Accurate prediction of calving in dairy cows by applying feature engineering and machine learning

Jorge A. Vázquez-Diosdado, Julien Gruhier, G. G. Miguel-Pacheco, Martin Green, Tania Dottorini, Jasmeet Kaler

Research output: Journal PublicationArticlepeer-review


Prediction of calving is key to dairy cow management. Current trends of increasing herd sizes globally can directly impact the time that farmers spend monitoring individual animals. Automated monitoring on behavioural and physiological changes prior to parturition can be used to develop machine learning solutions for calving prediction. In this study, we developed a machine learning algorithm for the prediction of calving in dairy cows. We demonstrated that temperature and activity index information retrieved from a commercial reticuloruminal bolus sensor can accurately predict calving from 1-day to 5-days in advance. The best prediction solution using data from 82 dairy cows, achieved up to 87.81 % in accuracy, 92.99 % in specificity, 75.84 % in sensitivity, 82.99 % in positive predictive value (PPV), 78.85 % in F-score, and 90.02 % in negative predictive value (NPV) on the test dataset when using information from 2-days in advance and all the subsets of feature characteristics (temperature + drinking + activity). The performance only decreased by 2.45 % points in accuracy, 0.74 % points in specificity, 6.41 % points in sensitivity, 2.45 % points in positive predictive value, 4.91 % points in F-score, and 2.44 % points in negative predictive value on the test dataset when using all feature characteristics and 5-days in advance information compared to using all features and information from 2-days in advance. Full evaluation of the performance of the prediction showed an improvement when using all the different subsets of feature characteristics together (temperature, activity, and drinking) compared to using temperature features only. When adding activity and drinking to the subset of temperature features, an average increase of 2.70, 1.52, 5.40, 4.39, 5.02, 2.13 % points in accuracy, specificity, sensitivity, PPV, F-score, and NPV, respectively, was obtained. Notably, evaluation of feature importance (i.e., relative weight of any given feature in relation to model prediction) showed that 3–5 (depending on the selected days in advance model) of the top ten features were derived from drinking behaviour, showing the relevance that this behaviour can have in the prediction of calving. This algorithm can provide a useful tool for automated calving prediction in dairy cows which has potential for improvement of health, welfare, and productivity in the dairy industry.

Original languageEnglish
Article number106007
JournalPreventive Veterinary Medicine
Publication statusPublished - Oct 2023
Externally publishedYes


  • Machine learning
  • Precision livestock farming
  • Prediction of calving
  • Reticuloruminal temperature bolus

ASJC Scopus subject areas

  • Food Animals
  • Animal Science and Zoology


Dive into the research topics of 'Accurate prediction of calving in dairy cows by applying feature engineering and machine learning'. Together they form a unique fingerprint.

Cite this