Classification of dairy cow excretory events using a tail-mounted accelerometer

Manod Williams*, Shu Zhan Lai

*Corresponding author for this work

Research output: Contribution to journalArticlepeer-review

4 Citations (Scopus)
81 Downloads (Pure)


Grazing livestock contributes to pasture nitrogen (N) through urine and faeces and N losses in pasture-based livestock systems are recognized as an important consideration for sustainable land management. Knowing the frequency and quantity of excreta produced in pasture-based dairy production systems could be useful for informing best management practice. The aim of this experiment was to determine whether data from tail-mounted accelerometers could be used to classify dairy cow excretory events. Ten non-lactating Holstein dairy cows were fitted with a tail-mounted accelerometer set to record data at 1 Hz and were individually observed for 3.3–5.3 h each. The recorded behaviours were urination, defecation, standing and lying (both left and right laterality). G-force acceleration values for X, Y and Z axes were downloaded and windows of varying sizes (3-, 6-, 9-, 12- and 15 s) were used to extract a set of basic features (mean, minimum, maximum and SD) from consecutive sequences of each behaviour. Windows were stepped forward by 1 s for feature extraction and five datasets were developed. Data for all cows were compiled and a random forest algorithm was used for model development. Ten times 10-fold stratified cross-validation (SCV) was used to evaluate data from all window sizes. Sensitivity and precision always exceeded 84% for standing and lying postures in both unbalanced and balanced datasets. Classification performance for excretory events improved significantly (P < 0.01) as window size increased. Due to performance, the 15 s window was selected for further tests with a full feature set. Random forest models were developed using a leave-one-cow-out cross-validation strategy (model developed using n-1 cows and evaluated on the held-out cow). Classification performance for standing and lying remained high (sensitivity & precision ≥ 91 %) but performance for excretory events was poor and highly variable. SCV results for excretory events were clearly optimistic and more data are needed for further testing. However, it may also be necessary to develop and test individual animal models for comparison because there may be considerable variation between animals for excretory events.
Original languageEnglish
Article number107187
Number of pages10
JournalComputers and Electronics in Agriculture
Early online date08 Jul 2022
Publication statusPublished - 01 Aug 2022


  • Accelerometer
  • Classification
  • Dairy cattle
  • Defecation
  • Precision livestock farming
  • Urination


Dive into the research topics of 'Classification of dairy cow excretory events using a tail-mounted accelerometer'. Together they form a unique fingerprint.

Cite this