Hostname: page-component-74656f9884-6grmk Total loading time: 0 Render date: 2026-11-06T08:03:33.031Z Has data issue: false hasContentIssue false

A supervised machine learning approach for the decision-making process on data-based culling in dairy farms

Published online by Cambridge University Press:  18 September 2025

Oscar R. Espinoza Sandoval
Affiliation:
Facultad de Zootecnia y Ecología, Universidad Autónoma de Chihuahua, Chihuahua, México
Juan C. Angeles-Hernandez
Affiliation:
Departamento de Medicina y Zootecnia de Rumiantes, Facultad de Medicina Veterinaria y Zootecnia, Universidad Nacional Autónoma de México, Ciudad de México, México
Agustín Corral-Luna
Affiliation:
Facultad de Zootecnia y Ecología, Universidad Autónoma de Chihuahua, Chihuahua, México
Felipe A. Rodríguez-Almeida
Affiliation:
Facultad de Zootecnia y Ecología, Universidad Autónoma de Chihuahua, Chihuahua, México
Pablo Pinedo
Affiliation:
Department of Animal Sciences, Colorado State University, Fort Collins, CO, USA
Albert De Vries
Affiliation:
Department of Animal Sciences, University of Florida, Gainesville, FL, USA
Santiago A. Utsumi
Affiliation:
Department of Animal and Range Sciences, New Mexico State University, Las Cruces, NM, USA
Einar Vargas-Bello-Pérez*
Affiliation:
Facultad de Zootecnia y Ecología, Universidad Autónoma de Chihuahua, Chihuahua, México
*
Corresponding author: Einar Vargas–Bello–Pérez; Email: einar.vargasbelloperez@reading.ac.uk
Rights & Permissions [Opens in a new window]

Abstract

This research paper aimed to develop a supervised machine learning (ML) approach that learns and predicts data-based culling from farm information that reflects the criteria of the decisions taken to cull a cow by a farm manager. Data containing the features of milk yield, days in milk, lactation number, pregnancy status, days open and days pregnant were obtained from January to December 2020 from dairy cows on a large dairy farm in northern Mexico. The cows were labelled as those that were data-based culled (Cull) and those that were not culled (Stay). Six supervised ML algorithms were evaluated in a binary classification including logistic regression (LR), Gaussian naïve Bayes (GNB), k-nearest neighbors (k-NN), support vector machine (SVM), random forest (RF) and multilayer perceptron (MLP). Each model was subjected to hyperparameter optimization using a grid search approach combined with tenfold stratified cross-validation. This ensured that the class imbalance (Cull vs. Stay) was accounted during model evaluation. The best-performing model for each algorithm was selected on cross-validated accuracy. To evaluate the prediction performance of the ML algorithms on both labels from learned data, the metrics accuracy, precision, recall, F1-score and the Matthews correlation coefficient (MCC) were employed. Accuracy among all classifiers was >0.90. The poorest prediction performance was observed in GNB (MCC = 0.50) and LR (MCC = 0.72). Conversely, the rest of the classifiers achieved superior prediction performance in learning the specific culling criteria, reaching an MCC score >0.91. Overall, culling criteria can be learned and predicted by ML algorithms and their performance varies among classifiers. This study identified RF as the best performing algorithm, but k-NN, SVM and MLP are possible candidates to be used in on-farm conditions. To increase their reliability, these approaches need to be tested in several farms, under different scenarios and varieties of features.

Information

Type
Research Article
Copyright
© The Author(s), 2025. Published by Cambridge University Press on behalf of Hannah Dairy Research Foundation.
Figure 0

Figure 1. Generalized pairs plot for the six features. Notes: The quantitative–quantitative (milk yield, days in milk open days and days of pregnancy) pairs are shown in scatterplots and density plots. The categorical–categorical (pregnancy status and lactation) pairs are shown in mosaic plots. The quantitative-categorical pairs are shown in boxplots and barcode plots. The diagonal (from the left upper to right lower) reflects the marginal distributions of the features. Green = data for the label Cull and blue = data for the label Stay.

Figure 1

Table 1. Summary and descriptive statics of both labels (Cull and Stay), for quantitative features

Figure 2

Table 2. Summary of the categorical features of the binary labels (Cull and Stay)

Figure 3

Figure 2. Normalized confusion matrix of the classifier algorithms employed. Notes: Each row corresponds to an instance of the true class (Stay or Cull), while each column corresponds to an instance of the predicted class. As a result, the diagonal elements indicate the proportion of correctly identified classes. Misclassification is reflected in the off-diagonal elements, which represent instances incorrectly assigned to a different class due to confusion.

Figure 4

Table 3. Results of the metrics for the evaluation of the prediction performance of the ML classifiers

Supplementary material: File

Espinoza Sandoval et al. supplementary material

Espinoza Sandoval et al. supplementary material
Download Espinoza Sandoval et al. supplementary material(File)
File 1.5 MB