You are on page 1of 10

Livestock Science 232 (2020) 103904

Contents lists available at ScienceDirect

Livestock Science
journal homepage: www.elsevier.com/locate/livsci

Automated computer vision system to predict body weight and average T


daily gain in beef cattle during growing and finishing phases
A. Cominottea, A.F.A. Fernandesa, J.R.R. Doreaa, G.J.M. Rosaa,b, M.M. Ladeirae,
E.H.C.B. van Cleeff, G.L. Pereirac, W.A. Baldassinic, O.R. Machado Netoc,d,

a
Department of Animal Sciences, University of Wisconsin - Madison, WI 53706, United States
b
Department of Biostatistics and Medical Informatics, University of Wisconsin, Madison, WI 53706, United States
c
School of Veterinary Medicine and Animal Science, Sao Paulo State University, Botucatu, SP 18618-681, Brazil
d
School of Agricultural and Veterinarian Sciences, São Paulo State University, Jaboticabal 14884-900, Brazil
e
Animal Sciences Department, Federal University of Lavras, MG 37200-00, Brazil
f
Federal University of Triângulo Mineiro, Iturama, MG 38280-000, Brazil

ARTICLE INFO ABSTRACT

Keywords: Frequent measurements of body weight (BW) in livestock systems are very important because they allow as-
Beef cattle sessing growth. However, real-time monitoring of animal growth through traditional weighing scales is stressful
Computer vision for animals, costly and labor-intensive. Thus, the objectives of this study were to: 1) assess the predictive quality
Image analysis of an automated computer vision system used to predict BW and average daily gain (ADG) in beef cattle; and 2)
Kinect®
compare different predictive approaches, including Multiple Linear Regression (MLR), Least Absolute Shrinkage
and Selection Operator (LASSO), Partial Least Squares (PLS), and Artificial Neutral Networks (ANN). A total of
234 images of Nellore beef cattle were collected during the weaning, stocker and feedlot phases. First, biometric
body measurements of each animal, such as body volume, area, length, and others, were performed using three-
dimensional images captured with the Kinect® sensor, and their respective BW were acquired using an electronic
scale. Next, the biometric measurements were used as explanatory variables in the four predictive approaches
(MLR, LASSO, PLS, and ANN). To evaluate prediction quality, a leave-one-out cross-validation was adopted. The
ANN was the best prediction approach in terms of Root Mean Square Error of Prediction (RMSEP) and squared
predictive correlation (r2). The results for Weaning were RMSEP = 8.6 kg and r2 = 0.91; for Stocker phase,
RMSEP = 11.4 kg and r2 = 0.79; and for Beginning of feedlot, RMSEP = 7.7 kg and r2 = 0.92. The ANN was
also the best method for prediction of ADG, with RMSEP = 0.02 kg/d and r2 = 0.67 for the period between
Weaning and Stocker, RMSEP = 0.02 kg/d and r2 = 0.85 for the Weaning and Beginning of Feedlot phase,
RMSEP = 0.03 kg/d and r2 = 0.80 for Weaning and Final of Feedlot phase, RMSEP = 0.10 kg/d and r2 = 0.51
for Stocker and Beginning of feedlot phase, and RMSEP = 0.09 kg/d and r2 = 0.82 for the Beginning and Final
of feedlot phase. Overall, the results indicate that the proposed automated computer vision system can be
successfully used to predict BW and ADG in real-time in beef cattle.

1. Introduction Alternatively, the use of computer vision system (CVS) has been
suggested as a tool to extract animal biometric measurements
Body weight (BW) is one of the most important traits in beef cattle (Gomes et al., 2016; Kashiha et al., 2014; Wang et al., 2008) from three-
production. It can be used to monitor animal growth to aid decision- dimensional (3D) images. The animal biometrics are then used as re-
making for best management strategies. Weighing scales are tradi- sponse variables in statistical models to predict BW (Gomes et al., 2016;
tionally used to measure BW in beef cattle. However, this practice is Li et al., 2014; Ozkaya et al., 2016). Thus, the use of CVS can be an
stressful for the animals, and it is also costly and labor-intensive alternative to monitor animal growth in real-time with minimal animal
(Schofield et al., 1999). stress, and much lower cost and labor. They are also noninvasive,

The authors would like to acknowledge the Coordenação de Aperfeiçoamento de Pessoal de Nível Superior (CAPES) and Fundação de Amparo à Pesquisa do Estado
se São Paulo (FAPESP), from Brazil, for the financial support to the first author.

Corresponding author at: Department of Animal Production, Sao Paulo State University, Botucatu, SP 18618-681, Brazil.
E-mail address: otavio.machado@unesp.br (O.R. Machado Neto).

https://doi.org/10.1016/j.livsci.2019.103904
Received 1 August 2019; Received in revised form 16 December 2019; Accepted 17 December 2019
Available online 18 December 2019
1871-1413/ © 2019 Elsevier B.V. All rights reserved.
A. Cominotte, et al. Livestock Science 232 (2020) 103904

automated, remote and the complex algorithms can be “cloud based” The collection time of infrared images (640 × 480 pixels) was 15
leading to immediate field deployment of results. seconds and 10 frames were obtained for each animal. The CVS pre-
The prediction quality of CVS is influenced by the type of biometric sented in this study corresponds to a library of custom codes written in
measurements used in predictive models (Fernandes et al., 2019; MATLAB (Release 2017b) (The MathWorks, 2017).
Gomes et al., 2016). In addition, the modeling approach may also play The animals were not in a movement when the images were taken.
an important role in generating accurate and precise predictions. For Each animal remained in a limited space during the image collection.
example, the set of features (i.e. biometric measurements) extracted Concomitantly, each animal was weighed in an electronic scale
from an image may present characteristics such as multicollinearity, (Coimma LTDA, model RUDD 300, Dracena, São Paulo, Brazil), with a
and linear or nonlinear relationships with the explanatory variables minimum and maximum capacity of 10 kg and 1500 kg, respectively
(i.e., BW). Thus, methods such as Least Absolute Shrinkage and Selec- and an accuracy of 0.5 kg.
tion Operator (LASSO), Partial Least Squares regression (PLS), and
Artificial Neural Network (ANN) could be potential predictive ap-
2.2. Image analysis
proaches to be tested in this type of dataset. Briefly, LASSO is a type of
regression where the coefficients are penalized and then shrunken to
The image analysis was an adaptation of the automated method
zero or excluded from the model (Tibshirani, 1996). The PLS extracts
developed by Fernandes et al. (2019). The original method was created
successive linear combinations of the predictors, called factors, which
for video analysis, but it was simplified to analyze images. The 10
address both explaining response variation and explaining predictor
frames obtained for each animal in each time point were processed in
variation. This method can also contribute to minimize the negative
three steps: 1) estimation of the distance from the ground to the
effect of multicollinearity (Carrascal et al., 2009). Lastly, ANN is a
camera; 2) image segmentation, and 3) feature extraction.
machine learning technique that can be used to improve the quality of
predictions due to their ability to model complex relationships between
variables such as nonlinearities and interactions (Gianola et al., 2011). 2.3. Estimation of the distance from the ground to the camera
Therefore, the objectives of this study were to: 1) assess the pre-
dictive quality of an automated CVS used to predict BW and the average In this step, the algorithm performed an estimation of the distance
daily gain (ADG) in a herd of Nellore steers, half-siblings, evaluated at between the camera and the ground based on the mode of the farthest
different growth stages; 2) compare the predictive quality of the fol- group of pixels Eq. (1).
lowing approaches: Multiple Linear Regression (MLR), LASSO, PLS, and
fdist = mode (maxPeak ) (1)
ANN. Few studies evaluate the predictive power of an automated CVS
and different predictive approaches to predict body weight on weight where fdist is the distance from the ground to the camera and maxPeak
gain at different stages of life of beef cattle. These systems can help to is the cluster of pixels above the 90th percentile of pixel distance
improve production practices. (Fig. 1A).

2. Material and methods


2.4. Image segmentation
All the animal procedures were approved by the Committee of
A series of criteria were checked in order to accept the frame as
Ethics in the use of animals of the School of Agricultural and
valid (Fernandes et al., 2019). Briefly, the first criterion to select the
Veterinarian Sciences of the São Paulo State University, Brazil, protocol
frame was to identify if the cattle was not connected to the border of the
number 007946/18.
scene. In this step, every object connected to the border of the region of
interest was removed from the logical image (e.g. if a cattle was pressed
2.1. Dataset
against a wall or a door, the correspondent frame was discarded). For
the estimation of the spine position, only the dorsal area between the
Sixty-two half-sib Nellore steers (chemically castrated) were used.
shoulder and the hip was used. Shoulder and hip were identified
During the stocker phase, animals were kept together in a pasture area
through an adaptation of Hough transformation for identification of
of 24 ha, consisting of Panicum maximum cv. Tanzania. During the dry
round objects (Hough, 1962) (Fig. 1B). The Hough transform is the
season (from April to September) and rainy season, the animals re-
method initially developed for identification of lines in the picture
ceived a mineral protein energy supplement at 3 g/kg of BW
plane of a grayscale image. The method consists of the identification of
(Supplementary material, Table S1). For the finishing phase, which
edge points and the assignment of an indicator value to each accumu-
lasted 173 days, the animals were transferred from the grazing system
lator corresponding to a specific line position and orientation
(weaning and stocker phase) to a feedlot. During the feedlot phase, a
(Fernandes et al., 2019). The highest peaks in the accumulator array
random sample of 48 animals was split into two groups of equal size.
correspond to the strongest lines (Szelisk, 2011). The Nellore cattle
One group with 24 animals was fed a diet composed of rumen-protected
head and tail were identified and removed as the regions in front of the
fat, and the other group of 24 animals received a diet without rumen-
shoulder and after the rump (Fig. 1C). The best segmented frame was
protected fat (Supplementary material, Table S2).
manually selected (one frame per animal by observer), and the ex-
A total of 234 images were collected in four time points during the
tracted features were used as in input variables to predict BW.
animal's life: weaning (8 months of age), stocker phase (15 months of
age), beginning of feedlot phase (20 months of age), and end of feedlot
phase (25 months of age) (Table 1). 2.5. Feature extraction
The time of birth was subdivided into two periods according to the
fixed-time artificial insemination (FTAI) of the cows: I FTAI (births in After feature extraction by the algorithm, a black and white frame
October) and II FTAI (births in November and early December). was saved (Fig. 2E). The extracted features were exported and saved in
In the three time points (Weaning, Stocker, and Beginning of fee- a comma-separated document (.csv).
dlot), 3D images were collected on 62 animals, while in the last time The body measurements were: area, volume, maximum length, 11
point (End of Feedlot) only 48 animals had the 3D images collected. The widths (W1 to W11) and 11 heights (H1 to H11) at equidistant locations
Kinect® model 1473 sensor (Microsoft Corporation, Redmond, WA) was in the dorsal part of the animal from the shoulders to the hip
used to capture the images, as previous described (Nir et al., 2018). The (Fig. 2A–D). The length, width and area of an object in an image can be
sensor was positioned at a specific distance from the pen floor (Fig. 1A). estimated by the sum of the respective pixels.

2
A. Cominotte, et al. Livestock Science 232 (2020) 103904

Table 1
Descriptive statistics of body weight and age during Weaning, Stocker, Beginning and End of feedlot phases of Nellore cattle.
Phases n Age (months)a ADG (kg/d) BW (kg) CVb (%)
Minimum (kg) Maximum (kg)

c
Weaning phase 62 8 (SD = 0.71) 0.05 (SD = 0.10) 202.3 (SD = 27.1) 13.7 114.0 266.0
Stocker phase 62 15 (SD = 0.71) 0.80 (SD = 0.15)d 213.9 (SD = 25.1) 11.7 138.0 277.0
Beginning of feedlot 62 20 (SD = 0.71) 0.76 (SD = 0.13)e 334.5 (SD = 29.2) 8.7 274.0 391.0
End of feedlot 48 25 (SD = 0.71) – 449.5 (SD = 47.5) 10.6 359.0 554.0

a
Standard deviation
b
Coefficient of variation
c
Weaning to Stocker phase
d
Stocker to Beginning of feedlot phase
e
Beginning to End of feedlot phase

2.6. Data analysis situations that involve a large number of correlated explanatory vari-
ables (Hans, 2009), as observed in the present study. The LASSO re-
For the statistical analysis, the Pearson correlation coefficient was gression was implemented along with the LOOCV using the "glmnet"
estimated between the animal BW and each of the features extracted function (cv. glmnet) of Friedman et al. (2010), implemented in the
from the 3D images using the PROC CORR of the software SAS 9.3. The software R. In this package, a coordinate descent algorithm is im-
features with correlation P < 0.05 were maintained of the model. plemented for optimization of model adjustment parameters. The de-
The explanatory variables were collected for each time point scription of the developed LASSO models for each time point can be
(Weaning, Stocker, Beginning of Feedlot, and End of Feedlot phase) and found in Table 2.
used to predict each BW. Four predictive approaches were used: 1)
Multiple Linear Regression; 2) Partial Least Squares; 3) LASSO 2.6.3. Partial Least Squares regression
Regression; and 4) Artificial Neural Networks. A leave-one-out cross- A Partial Least Squares (PLS) regression was performed with SAS
validation (LOOCV) was performed to assess predictive quality of each JMP Pro 13 (SAS Institute Inc., Cary, NC) to predict BW. Briefly, PLS
approach. The predicted BW were used then to predict the average jointly decompose the input matrix, X, and the output vector, Y, into
daily gain (ADG) for each growth phase: 1) Weaning to Stocker; 2) matrices which contain only the mutually relevant components
Weaning to Beginning of Feedlot; 3) Weaning to End of Feedlot; 4) (Wold, 1966). To accomplish that, the coupled decompositions is de-
Stocker to Beginning of Feedlot; 5) Stocker to End of Feedlot; and 6) scribed in Eq. (3).
Beginning of Feedlot to End of Feedlot. (3)
X = TPT · Y = TC T

2.6.1. Multiple linear regression where: is an orthogonal matrix common to both X and
A multiple linear regression (MLR) model can be expressed as: Y and is referred to as the matrix of scores. The matrices
and are the so called loadings of the individual input and
Y = B0 + B1 X1 + B2 X2 + . . . .+ Bk Xk + (2)
output matrices, while r refers to the rank of the input matrix and is
where Y is the response variable; X1, X2, . . ., Xk are the exploratory upper bounded as r ≤ m (Wold, 1966). An input-output relationship
variables; ɛ is the vector of errors (residues); and B0, B1, .. ., Bk are the can be established between X and Y, since the PLS decomposition
coefficients of the model. constrain X and Y to be in the same column space covered by the score
A LOOCV approach was implemented in the R software using the matrix.
TrainControl function and the "LOOCV" method of the Caret package In this study, the NIPALS (Nonlinear Iterative Partial Least Squares)
(https://cran.r-project.org/web/packages/caret/caret.pdf), where Y algorithm was used to find the first group of factors. The number of
consisted of the animal's BW and the explanatory variables X were the factors retained in the model was determined using a LOOCV and
features obtained through Kinect®. Predictive Residual Sum of Squares (PRESS). The model that reached
the lowest PRESS value in the cross validation was chosen. The de-
2.6.2. Least Absolute Shrinkage Selection regression scription of developed PLS models can be found in Table 2.
The LASSO model estimates the parameters (i.e., regression coeffi-
cients) by shrinkage, with a penalty on the least significant variables of 2.6.4. Artificial Neural Network
the model. This is a form of regularized or "penalized" regression, in An Artificial Neural Network (ANN) approach was implemented
which L1 (LASSO) regularization is introduced in the standard multiple using the open-source software H2O (https://cran.r-project.org/web/
linear regression procedure, using a composite cost function to optimize packages/h2o/h2o.pdf), with the statistical software R (R
the regression coefficients. This regression model is indicated for Core Team, 2016). The hyperparameters, such as the number of layers,

Fig. 1. A: Image used to estimate the distance from the camera to the ground without the animal presence, B: Shoulder and hip identified through an adaptation of
Hough transformation for the identification of round objects, C: Image of the dorsal area of the segmented animal after the identification of round objects.

3
A. Cominotte, et al. Livestock Science 232 (2020) 103904

Fig. 2. Extraction of the body measurements in equidistant locations in the dorsal part of the animal, from the shoulders to the hip. A: Area and length measurement,
B: 11 width measurements, C: Height measured at 11 points along the dorsum and D: body volume, E: Black and white frame saved after extraction of the image
characteristics.

Table 2
Models developed for Artificial Neutral Networks (ANN), Partial Least Squares (PLS), and Least Absolute Shrinkage and Selection Operator (LASSO).
Item Phases
Weaning Stocker Beginning of feedlot End of feedlot Complete

ANN
1st Neural Layer Unit 15 15 15 15 15
2nd Type of Neural Layers Maxout 150 Maxout 150 Maxout 150 Maxout 150 Maxout 150
Epochs 20 20 20 20 20
L1a 0.000069 0.000069 0.000069 0.000069 0.000069
L2b 0.000028 0.000028 0.000028 0.000028 0.000028
Input dropout ratio 0 0 0 0 0
Hidden dropout rate 0 0 0 0 0
PLSc
Number of factors 2 3 3 14 6
LASSO
Lambda 1.35 1.50 0.62 0.41 0.35

a
L1: Lasso regularization.
b
L2: Ridge regularization.
c
NIPALS method: algorithm of nonlinear interactive partial interval used to calculate the components of the PLS regression

the number of neurons in each layer, the learning rate, etc. were de- dropout (Zou and Hastie, 2005; Hastie et al., 2009). The regularization
fined following the search strategy described in Dórea et al. (2018). of L2 restricts the sum of the square weights, also called the weight
More detailed information about hyperparameter values and the search decay, which is analogous to the ridge regression used for linear models
criteria can be found in Table 3. Final ANN hyperparameter values after (Zou and Hastie, 2005; Hastie et al., 2009). In the present study, we
search are presented in Table 2. Each template with its respective ANN combined the two penalization methods (L1 and L2) to control over-
structure was trained through LOOCV with the h2o.deeplearning fitting (Table 2). For all the stages of animal growth, ANN presented
function. ADADELTA was the adaptive learning rate algorithm used in "Maxout" as a function of activation with 150 units (neurons) in the
all ANNs (Zeiler and Fergus, 2014). hidden layers (Table 2).
Similarly to Dórea et al. (2018), a strategy to reduce ANN over-
fitting with the use of Lasso (L1) and Ridge (L2) regularization was 2.6.5. Variance inflation factor
adopted. In ANN, the regularization of L1, also known as flexible net- Multicollinearity is a condition that occurs when some predictor
work, restricts the absolute value of weights, leading to a sparse vector variables are correlated with each other in the model (Tamura et al.,
during optimization (i.e., very close to zero) that has effect on the 2019). A high correlation between heights and/or widths was evident

4
A. Cominotte, et al. Livestock Science 232 (2020) 103904

Table 3
Hyperparameters and search criteria used in Artificial Neutral Networks (ANN). The hyperparameters were combined to find the best ANN structure.
Grid search: Hyperparameters and search criteria
Hyperparameters

Activation Function Hidden layers Prop. Drop. Ent.a L1b L2c


Rectifier 2 0 0 0
Tanh 8 0.25 0.0001 0.0001
Maxout 20 0.000001 0.000001
RectieferWithDropout 40
TanhWithDropout 50
MaxoutWithDropout 60
80
100
110
120
130
150
20,20
30,30,30
25,25,25,25
Network searchd
strategy max_runtime_secse max_modelsf stopping_metricg

a
Input dropout ratio.
b
L1 = Lasso Regularization.
c
L2 = Ridge Regularization.
d
RandomDiscrete = Get a random search of all combinations of its hyperparameters.
e
max_runtime_secs = Maximum execution time in seconds for all grid search.
f
max_models = Maximum number of models searched in the grid.
g
stoping_metric = Function used for early stop based on no improvement in model metric (in this case, metric defined as mean squared error).

from the estimated correlation matrix between the explanatory vari- 1961) to provide an indication of the adequacy of the model for pre-
ables. Hence, their collinearity was evaluated through the Variation diction. The mean bias represents the error in the central tendency (to
Inflation Factor (VIF) test for each explanatory variable using the evaluate whether the predicted values are above or below the pre-
function (vif) of the "car" package (https://cran.r-project.org/web/ dicted), slope bias represents errors due to regression, and the random
packages/car/car.pdf) implemented in software R (Eq. (4)): component is the variance that cannot be explained by linear regression
(Tedeschi, 2006). The models were evaluated using the Model Eva-
1
VIFi = luation System (Tedeschi, 2006) (MES, College Station, TX; http:
1 Ri2 (4) //nutritionmodels.t amu.edu/mes.html).
where Ri2is the coefficient of determination of the regression for each
explanatory variable (i = 1, 2, …, k). Whenever VIFi ≥ 10, the ex- 3. Results and discussion
planatory variable Xi was excluded from the model, and the predictive
ability of the MLR model was evaluated. The present study used an autonomous method for real-time 3D
image segmentation and extraction of biometric characteristics for BW
2.6.6. Model evaluation prediction of Nellore cattle in commercial farms. Frames with better
The model evaluation was conducted as described by sharpness and image positioning were selected, generating 24 distinct
Tedeschi (2006). The squared correlation (r2) between the predicted segments (Fig. 1). From these, 15 were considered as biometric char-
and observed values was used to assess the precision of the developed acteristics measured through 3D images and were used as explanatory
equations. The concordance correlation coefficient (CCC; Lin, 1989), variables: dorsal area, body volume, length, six widths corresponding to
mean bias and root mean square error of prediction (RMSEP) were also the animal's anterior part (L1 to L3) and posterior part (L9 to L11), and
calculated as additional measures of prediction quality. The CCC was six heights corresponding to the height of the withers (A1 to A3) and
estimated (Eq. (5)) according to Lin (1989): the croup height (A9 to A11). Biometric measurements obtained by 3D
images have been described as good predictors of BW for animals with a
^ = ^ × Cb (5)
c high correlation between these and BW (Fernandes et al., 2019;
cov (X , Y ) Gomes et al., 2016; Kongsro, 2014; U et al., 2015).
r= Moderate to high positive correlations were observed in this study
x y (6)
between PC and several biometric characteristics measured from 3D
where the first component ( ^ ) is the correlation coefficient estimate (r; images. However, there were variations in which biometric variables
Eq. (6) that may be computed using the covariance of x and y and were strongly correlated with each other at different times of image
standard deviation of x and y) that measures the precision. The second collection. It is likely that such variations in the intensity of the cor-
component (Cb) is the polarization correction factor that represents how relation between variables may have some influence on the accuracy
much the regression line deviates from the slope of the unit (45°). The and precision of predictions for BW and ADG (Fig. 4). Overall, it can be
Cb factor varies from 0 to 1. noticed a low correlation of segmentation measures (heights and
The mean bias (MB) is given by the mean deviation between the lengths) between each other at weaning (Fig. 3a) and an increase in the
predicted and observed values (Cochran and Cox et al., 1992). The intensity of correlations between these biometric variables in later
mean square error of prediction (MSEP) is the sum of the quadratic image captures, especially between lengths and between heights, both
difference between the observed and the predicted values of the model at rearing (Fig. 3b) and at the beginning (Fig. 3c) and end of feedlot
divided by the number of observations (n) (Conway, 1979). The MSEP (Fig. 3d).
was decomposed into mean bias, slope bias and random errors (Theil, The variables selected and used in this study were those with a high

5
A. Cominotte, et al. Livestock Science 232 (2020) 103904

Fig. 3. Correlation between the response variable and the explanatory variables for body weight obtained through the Kinect® sensor. A: Weaning, B: Stocker, C:
Beginning of Feedlot and D: End of Feedlot.

correlation with BW (p < 0.05) and were concordant for the four points In general, biometric variables obtained from three-dimensional
of images collect. This fact may suggest that the selection of variables images are strongly correlated to BW, however, training and validation
should be performed with methods that also consider the correlation of prediction models of the different methods proposed are important,
between explanatory variables, generating not only a set of variables mainly due to the ability to model biometric data with different degrees
with high predictive power, but also little correlated. For this purpose, of correlation between them and non-linear effects (Hastie et al., 2009).
they can be used to select Stepwise (Fernandes et al., 2019) or Markov- The evaluation of each model was determined comparatively (Tables 4
Blanket variables through the Bayesian Network (Dórea et al., 2018). and 5). The MRL showed higher values of RMSEP and normalized
Although, the simple correlation has been used between explanatory RMSEP (RMSEP/Mean) in all scenarios analyzed (from 4.25 to 7.9%),
variables and response object, some of the prediction methods used which was also maintained in ADG (from 7.71 to 74.7%).
here can model data correlated by reduction of dimensionality and By the decomposition of the RMSEP, as described in
penalty as PLS and LASSO, respectively. Tedeschi (2006), a higher proportion of random errors (% random

6
A. Cominotte, et al. Livestock Science 232 (2020) 103904

Fig. 4. A–D: Graphics generated through Multiple Linear Regression (MLR) for each animal in four time point from the values of observed BW vs. predicted BW, E:
Graphics generated through MLR for each animal from the values of observed BW vs. predicted BW.

Table 4
Parameters for evaluating body weight predictions in different phases and predictive models.
Itemb Slope ( ± SE) H0: b = 1 r² Mean bias (kg) CCCc RMSEP (kg)d RMSEP / Mean (%) Decomposition of MSEP (%)
Mean bias Slope bias Random error

Weaning
ANN 0.82 ( ± 0.03)a 0.01 0.91 0.09 0.94 8.63 4.26 0.01 31.49 68.50
PLS 0.79 ( ± 0.05)a 0.01 0.79 0.00 0.88 12.61 6.23 0.00 20.91 79.09
LASSO 0.72 ( ± 0.05)a 0.02 0.73 −0.41 0.84 14.18 7.00 0.69 24.48 71.43
MLR 0.74 ( ± 0.08)a 0.03 0.67 −0.46 0.81 16.00 7.90 0.09 19.50 80.41
Stock phase
ANN 0.75 ( ± 0.04)a 0.01 0.79 −0.37 0.87 11.40 5.32 0.11 29.74 70.15
PLS 0.76 ( ± 0.05)a 0.06 0.76 0.00 0.86 12.20 5.70 0.00 23.80 76.20
LASSO 0.66 ( ± 0.05)a 0.01 0.70 −0.12 0.81 13.63 6.37 0.01 38.94 61,05
MLR 0.70 ( ± 0.06)a 0.08 0.63 −0.15 0.79 15.19 7.10 0.01 22.91 77.08
Beginning feedlot
ANN 0.91 ( ± 0.03) 0.07 0.92 −0.97 0.96 7.78 2.32 1.57 11.06 87.37
PLS 0.87 ( ± 0.04)a 0.04 0.87 0.00 0.93 10.26 3.06 0.00 12.57 87.43
LASSO 0.83 ( ± 0.04)a 0.07 0.84 0.04 0.91 11.26 3.36 0.00 17.31 82.69
MLR 0.82 ( ± 0.05) 0.03 0.76 0.10 0.87 14.23 4.25 0.01 13.14 86.65
End of feedlot
ANN 0.85 ( ± 0.05)a 0.01 0.85 −1.26 0.91 18.14 4.48 0.48 13.46 86.06
PLS 0.90 ( ± 0.04) 0.03 0.90 0.00 0.95 14.18 3.15 0.00 9.12 90.88
LASSO 0.85 ( ± 0.05)a 0.01 0.79 −0.63 0.90 19.83 4.41 0.10 12.28 87.62
MLR 0.75 ( ± 0.07) 0.03 0.66 0.03 0.81 27.68 6.15 0.00 17.32 82.68

a
Slope test (b = 1, P > 0.05).
b
Artificial Neutral Networks (ANN); Partial Least Squares (PLS); Least Absolute Shrinkage and Selection Operator (LASSO); Multiple Linear Regression (MLR).
c
Concordance Correlation Coefficient (CCC).
d
Root Mean Square Error of Prediction (RMSEP).

7
A. Cominotte, et al. Livestock Science 232 (2020) 103904

Table 5
Parameters for the evaluating average daily gain in different phases and predictive models.
Itemh Slope ( ± SE) H0: b = 1 r² Mean bias (kg/d) CCCi RMSEP (kg/d)j RMSEP / Mean (%) Decomposition of MSEP (%)
Mean bias Slope bias Random error

W – Sa
ANN 0.74 ( ± 0.06)g 0.02 0.67 0.00 0.81 0.02 37.03 0.12 20.15 79.73
PLS 0.62 ( ± 0.07)g 0.01 0.52 0.00 0.71 0.03 55.55 0.00 29.59 70.41
LASSO 0.49 ( ± 0.07)g 0.01 0.36 0.00 0.62 0.03 55.55 0.03 41.63 58.34
MLR 0.44 ( ± 0.10)g 0.01 0.23 0.00 0.48 0.04 74.07 0.05 52.13 47.82
S – BFb
ANN 0.89 ( ± 0.04)g 0.03 0.85 0.00 0.92 0.02 5.68 1.11 7.19 91.70
PLS 0.83 ( ± 0.06)g 0.09 0.74 0.00 0.86 0.03 7.85 0.00 10.75 89.25
LASSO 0.74 ( ± 0.06)g 0.03 0.65 0.00 0.80 0.04 10.47 0.08 19.03 80.89
MLR 0.73 ( ± 0.08)g 0.03 0.56 0.00 0.74 0.05 13.08 0.01 13.63 86.36
W – EFc
ANN 0.84 ( ± 0.06)g 0.01 0.80 0.01 0.89 0.03 6.39 0.11 12.09 87.80
PLS 0.87 ( ± 0.05)g 0.03 0.82 0.00 0.90 0.03 6.39 0.16 8.89 90.95
LASSO 0.80 ( ± 0.07)g 0.00 0.72 0.00 0.85 0.04 8.52 0.08 13.62 86.30
MLR 0.91 ( ± 0.09) 0.33 0.68 0.00 0.82 0.05 10.66 0.47 2.02 97.51
S – BFd
ANN 0.54 ( ± 0.06)g 0.01 0.51 0.00 0.69 0.10 11.01 0.20 42.47 57.33
PLS 0.52 ( ± 0.06)g 0.01 0.49 0.02 0.67 0.10 11.01 0.00 44.04 55.96
LASSO 0.46 ( ± 0.07)g 0.01 0.40 0.01 0.60 0.11 12.11 0.01 48.30 51.69
MLR 0.40 ( ± 0.09)g 0.01 0.22 0.00 0.46 0.14 15.41 0.00 37.57 62.43
S – EFe
ANN 0.82 ( ± 0.06)g 0.01 0.76 0.00 0.87 0.06 9.28 0.29 13.22 86.49
PLS 0.83 ( ± 0.05)g 0.02 0.85 0.00 0.91 0.05 6.63 0.19 18.07 81.74
LASSO 0.79 ( ± 0.06)g 0.02 0.77 0.00 0.87 0.06 7.96 0.58 18.65 80.77
MLR 0.90 ( ± 0.08)g 0.28 0.71 0.01 0.84 0.07 7.71 2.08 2.45 95.47
BF – EFe
ANN 0.90 ( ± 0.06) 0.13 0.82 0.00 0.90 0.09 14.04 0.00 4.80 95.20
PLS 0.92 ( ± 0.06) 0.24 0.81 0.05 0.90 0.10 15.60 0.08 3.97 95.95
LASSO 0.87 ( ± 0.07)g 0.12 0.73 0.00 0.85 0.12 18.72 0.01 5.01 94.98
MLR 0.93 ( ± 0.10)g 0.55 0.62 0.01 0.78 0.16 24.96 1.06 0.75 98.19

a
Weaning– Stocker phase.
b
Weaning – Beginning of feedlot.
c
Weaning– End of feedlot.
d
Stock phase – Beginning of feedlo.t
e
Stock phase – End of feedlot
f
Beginning of feedlot– End of feedlot.
g
Slope test (b = 1, P > 0.05).
h
Artificial Neutral Networks (ANN); Partial Least Squares (PLS); Least Absolute Shrinkage and Selection Operator (LASSO); Multiple Linear Regression (MLR).
i
Concordance Correlation Coefficient (CCC).
j
Root Mean Square Error of Prediction (RMSEP).

error) is observed, in addition to a lower proportion of systematic errors BW and ADG compared to LASSO (Tables 4 and 5). Being this first
(% bias slope) and due to deviation from central tendency (% mean model, besides being more precise, more accurate as demonstrating the
bias), indicating the inability to improve prediction with changes in higher values of CCC and r2 and lower mean bias, also achieving a
model parameters when compared to the others. This fact was corro- better adjustment to the parameters of the model as indicated by the
borated by the CCC measurements, which indicates in a balanced way decomposition of the RMSEP.
the accuracy and precision as described by Lin (1989), and also the r2 Although LASSO and PLS have the capacity to deal with problems
and mean bias that indicated low accuracy in predicting values for this such as multicolinearity, LASSO ignores this problem, although it deals
model in relation to the others in all scenarios of image collection and well with nonlinear effects and, therefore, when selecting variables by
phases of growth and fattening. penalization (shrinkage) from those less correlated to the response
Multicollinearity among the variables was probably one of the main object, it can select variables correlated with each other as better pre-
reasons why the MRL did not obtain better predictions by the other dictors, which is the biggest problem of this approach, which appar-
methods. Multicollinearity increases the variation of regression coeffi- ently occurred in this study. On the other hand, the PLS in addition to
cients, making them unstable (Hastie et al., 2009). This problem occurs selecting variables that present high explained variance, also tends to
because many resources are extracted from the same images that select those that are strongly correlated to the response object
naturally tend to be strongly correlated. On the other hand, models (Kuhn and Johnson, 2013). In this sense, by selecting the variables by
such as LASSO and PLS have the capacity to deal with multicollinearity the correlation with the response object and based on variance, it can
and overdimensioning of a data set more effectively than LMRs, al- cope better with correlated data and multicollinearity, as demonstrated
though applying very different techniques. These can penalize the by the results. In addition, the different behavior between LMR, LASSO
characteristics that have less contribution in the model (based on and PLS corroborate so that multicolinearity of data is in fact a problem
shrinkage of variables), and can reduce a variable to zero, such as the for this type of estimates, since the best predictions among them was
LASSO regression (Efron et al., 2004), or by another approach in which the method that best deals with this problem.
is applied the reduction of the dimension of data as in the use of PLS. In general, the ANN method showed greater precision in BW pre-
In general, PLS presented better predictions than LASSO, and even diction since it obtained the lowest RMSEP and normalized RMSEP in
than ANN with the data collected at the end of the feedlot period. comparison with the other approaches, except as highlighted above, at
RMSEP and RMSEP normalized were lower for PLS in all scenarios for the end of the feedlot, which will be discussed later (Table 4). Although

8
A. Cominotte, et al. Livestock Science 232 (2020) 103904

ANN did not always have the lowest mean bias, almost always (except a dependence between the predictive capacity of ANN to the data, in-
for FE) presented higher r2 and CCC indicating high accuracy in BW dicating that the reduction of samples combined with high multi-
prediction (Table 4). Thus, it is evident that ANN was able to deal with collinearity among explanatory variables at the end of the feedlot may
correlated data problems (multicollinearity) better than the other have caused worse predictions of BW by ANN.
models. In addition, it is possible that ANN may have captured non- As seen above, based on management, the predictive capacity of the
linear relationships between variables in a more effective manner when different models for ADG can be a little bit more explored, since they
compared to other predictive methods (Lin, 1989; Perai et al., 2010). are dependent on BW predictions, which in itself explains most of the
The ANN and other algorithms applied to machine learning can differences found for ADG estimates. As expected, the worst values of
present the problem of overfitting the models, as well as in PLS, but in RMSEP and r2 were obtained in the W-S phase. In this scenario, there
this case it is easily circumvented by cross validation (Kuhn and was a great advantage in predicting ANN compared to the other models,
Johnson, 2013). In this study, two penalties (l1 and l2) were applied, which was also observed in S-BF. In the other scenarios, ANN and PLS
avoiding overadjustments due to variables of low explanatory power obtained similar precision and accuracy of prediction, and in the S-EF
(Dórea et al., 2018), which seemed to be effective. However, the loss of phase there was a notable disadvantage of ANN being below all the
predictive ANN capacity at the end of the feedlot period is evident, other models. Finally, in the BF-EF phase, there was generally a higher
which could be partly explained by the reduction of samples in this normalized RMSEP than the other phases, except for the W-S, which
phase due to the lower number of individual pens, in which the animals can be explained by the slight increase in data variation (CV) and re-
were allocated. Thus, there was a smaller number for training and va- duction in the number of samples impacting the ADG prediction of all
lidation of ANN, which may have led to decreased performance in BW the models.
prediction. Therefore, the PLS method proved to be more stable when For many years the beef cattle industry has been very interested in
there was an alteration in the number of samples, maintaining good modeling animal growth to provide a mathematical summary of weight
predictive capacity in a set of small samples. This may suggest that in a evolution with age and then use it to compare or predict animal per-
larger sample set, both PLS and ANN may behave differently due to the formance (Venot et al., 2004). Real-time monitoring of the BW of ani-
larger sample number for training and validation. mals for slaughter is very important as a decision-making tool, as it
In addition, on average, the RMSEPs were higher in collections at allows better management in relation to nutrition, health, reproduction
Weaning and Stock Phase when compared to the Beginning feedlot, this and reduces stress. The low predictive error presented in this study
can be explained by factors such as maternal ability, a large difference indicates that computer vision systems can be used in both commercial
between weights, which is evidenced by the high C.V. both for Weaning and research environments as a potential tool to monitor animal
and Stock Phase (13.7% and 11.7%, respectively) and lower C.V. growth.
(8.7%) at the Beginning Feedlot period (Table 1). The PLS and ANN methods presented good ability to deal with re-
In the present study, the results suggest that the forage supply was current problems when analyzing biometric measurements. However,
not enough to meet the nutrient requirements of the cows at the end of ANN presented greater potential to be used in this type of analysis as it
gestation (due to the time of year). Consequently, there was no increase obtained lower predictive errors in almost all scenarios. Apparently, its
in birth weight, the time of birth significantly influenced weaning and worst performance was associated with a smaller sample set, which in
the weight at raising. Calves born in the FTAI I had higher weights practice is not expected to occur. In this sense, it is also important to
compared to the FTAI II, which agrees with the findings (Menezes et al., highlight that the cross validation was performed with animals from the
2013), and calves born in the FTAI I presented higher efficiency com- same herd and with the same environmental conditions. An external
pared to the others. validation is necessary when using these templates with other datasets.
However, this fact cannot always be considered, since birth time did Regarding the level of weighing automation in image capture and re-
not significantly influence birth weight, as found by Menezes et al. liable estimated return time of BW and ADG, it is still necessary to es-
(2013) and Carneiro et al. (2012). Probably the absence of the sig- tablish a procedure for segmentation and selection of variables that is
nificant effect of birth time on weaning weight is due to climate var- fast and can be automatically developed.
iation in the region. Therefore, although they help to answer the var-
iations in prediction for each method, the addition of information such 4. Conclusion
as time of birth and weight at weaning goes against the purpose of
automation of weighing by three-dimensional images, because the Automated computer vision system has the potential to predict body
collections of some extra variables can be extremely laborious, so they weight and performance in Nellore cattle rearing in pasture or feedlot.
were not included for BW prediction in this work. In addition, However, future studies with a greater number of animals are needed to
Fernandes et al. (2019) found no visible improvement with the inclu- improve this technology results.
sion of body measurements (obtained in locus), body type, gender and
other additional variables in a study involving beef cattle. Declaration of Competing Interest
It is worth mentioning that the weighing in the Stock Phase (to
pasture) was carried out at the end of the drought and there may have The authors certify that they have NO affiliations with or involve-
been different levels of compensatory gain and adaptation after ment in any organization or entity with any financial interest or non
weaning. On the other hand, the Beginning Feedlot period, which oc- financial interest in the subject matter or materials discussed in this
curred after the rain season, in which there is a better supply of food, study.
less influence of weaning weight, and a social order of establishment,
lower RMSEP and higher r2 and CCC were found for BW prediction for Acknowledgements
all methods (Table 4). Finally, the feedlot was carried out in individual
pens and with a higher level of concentrate in the diets would explain This research was granted by São Paulo Research Foundation
the higher C.V. level in relation to the Beginning Feedlot period. (FAPESP), grant numbers: 2017/20812-0 and 2017/02057-0. This
However, at this stage the animals tend to be more mature and study was financed in part by the Coordenação de Aperfeiçoamento de
possibly there is less conformational variation, which would help to Pessoal de Nível Superior – Brasil (CAPES) – Finance Code 001.
have an improvement in BW predictions. Reinforcing what was pre-
viously proposed, it would not be expected a worse prediction by ANN, Supplementary materials
since in situations of greater data variation (such as weaning and
raising) it performed better than other approaches, which corroborates Supplementary material associated with this article can be found, in

9
A. Cominotte, et al. Livestock Science 232 (2020) 103904

the online version, at doi:10.1016/j.livsci.2019.103904. Agriculture VII. CCTA 2013. IFIP Advances in Information and Communication
Technology. Springer, Berlin, Heidelberg, pp. 42–49.
Lin, L.I.-K., 1989. A concordance correlation coefficient to evaluate reproducibility.
References Biometrics 45, 255–268. https://doi.org/10.2307/2532051.
Menezes, L.M.de, Pedrosa, A.C., Pedroso, D., Fernandes, S., 2013. Desempenho de bo-
Carneiro, L.C., Silva, J.C.do C., Mendes, G.P., Ferreira, I.C., dos Santos, R.M., 2012. Efeito vinos nelore e cruzados blonde d'aquitaine x nelore do nascimento ao desmame. Rev.
do mês de parição na taxa de gestação subsequente e no peso ao desmame dos be- Bras. Saúde e Prod. Anim. 14, 177–184. https://doi.org/10.1590/S1519-
zerros de vacas Nelore. Acta Sci. Vet. 40, 1–5. 99402013000100018.
Carrascal, L.M., Galván, I., Gordo, O., 2009. Partial least squares regression as an alter- Nir, O., Parmet, Y., Werner, D., Adin, G., Halachmi, I., 2018. 3D computer-vision system
native to current regression methods used in ecology. Oikos 5, 681–690. https://doi. for automatically estimating heifer height and body mass. Biosyst. Eng. 173, 4–10.
org/10.1111/j.1600-0706.2008.16881.x. https://doi.org/10.1016/j.biosystemseng.2017.11.014.
Cochran, W. G., and Gertrude M. Cox. Notes on the statistical analysis of the results. Ozkaya, S., Neja, W., Krezel-Czopek, S., Oler, A., 2016. Estimation of body weight from
(1992). body measurements and determination of body measurements on Limousin cattle
Conway, F., 1979. Prediction and Improved Estimation in Linear Models. Math. Gaz. 63, using digital image analysis. Anim. Prod. Sci. 56, 2060–2063. https://doi.org/10.
74–75. https://doi.org/10.2307/3615245. 1071/AN14943.
Dórea, J.R.R., Rosa, G.J.M., Weld, K.A., Armentano, L.E., 2018. Mining data from milk Perai, A.H., Moghaddam, H.N., Asadpour, S., Bahrampour, J., Mansoori, G., 2010. A
infrared spectroscopy to improve feed intake predictions in lactating dairy cows. J. comparison of artificial neural networks with other statistical approaches for the
Dairy Sci. 101, 5878–5889. https://doi.org/10.3168/jds.2017-13997. prediction of true metabolizable energy of meat and bone meal. Poult. Sci. 89,
Efron, B., Hastie, T., Johnstone, I., Tibshirani, R., Ishwaran, H., Knight, K., Loubes, J.M., 1562–1568. https://doi.org/10.3382/ps.2010-00639.
Massart, P., Madigan, D., Ridgeway, G., Rosset, S., Zhu, J.I., Stine, R.A., Turlach, B.A., Schofield, C.P., Marchant, J.A., White, R.P., Brandl, N., Wilson, M., 1999. Monitoring pig
Weisberg, S., Johnstone, I., Tibshirani, R., 2004. Least angle regression. Ann. Stat. 32, growth using a prototype imaging system. J. Agric. Eng. Res. 72, 205–210. https://
407–499. https://doi.org/10.1214/009053604000000067. doi.org/10.1006/jaer.1998.0365.
Fernandes, A.F.A., Dórea, J.R.R., Fitzgerald, R., Herring, W., Rosa, G.J.M., 2019. A novel Szelisk, R., 2011. Computer Vision: Algorithms and Applications. Springer, London.
automated system to acquire biometric and morphological measurements and predict https://doi.org/10.1007/978-1-84882-935-0.
body weight of pigs via 3D computer vision. J. Anim. Sci. 97, 496–508. https://doi. Theil, H., 1961. Economic forecasts and policy, North Holland, Amsterdam (1961).
org/10.1093/jas/sky418. Tamura, R., Kobayashi, K., Takano, Y., Miyashiro, R., Nakata, K., Matsui, T., 2019. Mixed
Friedman, J., Hastie, T., Tibshirani, R., 2010. Regularization paths for generalized linear integer quadratic optimization formulations for eliminating multicollinearity based
models via coordinate descent. J. Stat. Softw. 33, 1–22. https://doi.org/10.18637/ on variance inflation factor. J. Glob. Optim. 73, 431–446. https://doi.org/10.1007/
jss.v033.i01. s10898-018-0713-3.
Gianola, D., Okut, H., Weigel, K.A., Rosa, G.J.M., 2011. Predicting complex quantitative Core Team, R, 2016. R: a Language and Environment for Statistical Computing. R
traits with Bayesian neural networks: a case study with Jersey cows and wheat. BMC Foundation for Statistical Computing.
Genet. 12, 87. https://doi.org/10.1186/1471-2156-12-87. Tedeschi, L.O., 2006. Assessment of the adequacy of mathematical models. Agric. Syst.
Gomes, R.A., Monteiro, G.R., Assis, G.J.F., Busato, K.C., Ladeira, M.M., Chizzotti, M.L., 89, 225–247. https://doi.org/10.1016/j.agsy.2005.11.004.
2016. Technical note: estimating body weight and body composition of beef cattle Tibshirani, R., 1996. Regression selection and Shrinkage via the Lasso. J. R. Stat. Soc. B
trough digital image analysis. J. Anim. Sci. 94, 5414–5422. https://doi.org/10.2527/ 58, 267–288. https://doi.org/10.2307/2346178.
jas.2016-0797. Venot, E., Piles, M., Renand, G., & Jaffrézic, F.2004. Genetic Analysis of Growth Curve
Hastie, Trevor, Tibshirani, Robert, Friedman, J., 2009. The Elements of Statistical Parameters for Beef Cattle Using Markov Chain Monte Carlo Estimation Methods. In:
Learning: Data Mining, Inference, and Prediction, 2nd ed. Springer, New York. van der Honing, Y., Hofer, A., Cenkvári, E., Fourichon, C., Chilliard, Y., Lazzaroni, C.,
https://doi.org/10.1007/978-0-387-84858-7. Bodin, L., Wenk, C., Martin-Rosset, W., and Hermansen, J.E. (Eds.), 55th Annual
Hans, C., 2010. Model uncertainty and variable selection in Bayesian lasso regression. Meeting of the European Association for Animal Production, Bled, Slovenia.
Statistics and Computing 20 (2), 221–229. Wageningen Academic Publishers, Wageningen, pp. 297.
Hough, P.V.C., 1962. Method and means for recognizing complex patterns. US Pat. 3, Wang, Y., Yang, W., Winter, P., Walker, L., 2008. Walk-through weighing of pigs using
069. 654. https://doi.org/10.1007/s10811-008-9353-1. machine vision and an artificial neural network. Biosyst. Eng. 100, 117–125. https://
Kashiha, M., Bahr, C., Ott, S., Moons, C.P.H., Niewold, T.A., Ödberg, F.O., Berckmans, D., doi.org/10.1016/j.biosystemseng.2007.08.008.
2014. Automatic weight estimation of individual pigs using image analysis. Comput. Wold, H., 1966. Estimation of principal components and related models by iterative least
Electron. Agric. 107, 38–44. https://doi.org/10.1016/j.compag.2014.06.003. squares (Ed.) In: Krishnaiah, P.R. (Ed.), Multivariate Analysis. Academic Press, N.Y,
Kongsro, J., 2014. Estimation of pig weight using a Microsoft Kinect prototype imaging pp. 391.
system. Comput. Electron. Agric. 109, 32–35. https://doi.org/10.1016/j.compag. Zeiler, M.D., Fergus, R., 2014, September. Visualizing and understanding convolutional
2014.08.008. networks. European conference on computer vision. Springer, Cham, pp. 818–833.
Kuhn, M., Johnson, K., 2013. Applied Predictive Modeling. Springer, New York Ed.. Zou, H., Hastie, T., 2005. Regularization and variable selection via the elastic net. J. R.
https://doi.org/10.1007/978-1-4614-6849-3. Stat. Soc. Ser. B Stat. 67, 301–320. Methodol. https://doi.org/10.1111/j.1467-9868.
Li, Z., Luo, C., Teng, G., Liu, T., 2014. Estimation of Pig Weight by Machine Vision: A 2005.00503.x.
Review (Eds.) In: Li, D., Chen, Y. (Eds.), Computer and Computing Technologies in

10

You might also like