Next Article in Journal
Ergothioneine Improves the Quality of Boar Sperm During In Vitro Liquid Preservation by Regulating Mitochondrial Respiratory Chain
Previous Article in Journal
Monitoring Behavior and Welfare of Cattle in Response to Summer Weather in an Arizona Rangeland Pasture Using a Commercial Rumen Bolus
Previous Article in Special Issue
A Comparison of Artificial Intelligence and Human Observation in the Assessment of Cattle Handling and Slaughter
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Communication

Prediction of Weight and Body Condition Score of Dairy Goats Using Random Forest Algorithm and Digital Imaging Data

by
Mateus Alves Gonçalves
1,
Maria Samires Martins Castro
1,
Eula Regina Carrara
1,
Camila Raineri
2,
Luciana Navajas Rennó
1 and
Erica Beatriz Schultz
1,*
1
Department of Animal Science, Federal University of Viçosa, University Campus, PH. Rolfs Ave, Viçosa 36570-900, MG, Brazil
2
School of Veterinary Medicine and Animal Science, Federal University of Uberlândia, Uberlândia 38408-144, MG, Brazil
*
Author to whom correspondence should be addressed.
Animals 2025, 15(10), 1449; https://doi.org/10.3390/ani15101449
Submission received: 24 March 2025 / Revised: 1 May 2025 / Accepted: 14 May 2025 / Published: 16 May 2025

Simple Summary

On dairy goat farms, monitoring weight and body condition is essential for proper animal management. Currently, these measurements are recorded manually, which can be time-consuming and inconsistent. This study explores the use of digital images and artificial intelligence to estimate weight and body condition in dairy goats. By analyzing images of 154 dairy goats, we tested whether machine learning models could accurately predict these traits. The results showed that digital imaging is a reliable method for estimating body weight, providing a faster and more cost-effective alternative to traditional techniques. However, the approach was less effective in classifying body condition, suggesting that further improvements are needed. This research highlights the potential of digital tools to enhance farm efficiency, reducing labor while improving data accuracy for better decision-making in animal care.

Abstract

The aim of study was to evaluate the use of digital images to predict body weight (BW) and classify the body condition score (BCS) of dairy goats. A total of 154 female Saanen and Alpine goats were used to obtain eight body measurements features from digital images: withers height (WH), rump height (RH), body length (BL), chest depth (D), paw height (PH), chest width (CW), rump width (RW), rump length (RL). All animals were weighed using manual scales, and their BCS was evaluated on a scale of 1 to 5. For classification purposes, the BCS was grouped into three categories: low (1–2), moderate (2–3), and high (>3). Pearson’s correlation analysis and the Random Forest algorithm were performed. It was possible to predict BW using image features with an R2 of 0.87, with D (22.14%), CW (18.93%) and BL (15.47%) being the most important variables. For the BCS, the classification accuracy was 0.4054 with the CW (20.38%) the most important variable followed by RH and RL with 15.78% and 12.63%, respectively. It was concluded that digital image features can be used to obtain precise estimates of body weight, but it is necessary to increase data variability to improve the BCS classification of dairy goats.

1. Introduction

Measuring the weight and body condition score (BCS) of dairy goats is essential for monitoring their nutritional and health status, which significantly impacts the productive and economic farm efficiency [1,2]. Although important, continuous body weight (BW) monitoring in dairy systems as highlighted by Martins et al. [3] is labor-intensive, requiring specialized equipment, manual labor, and animal restraint. Furthermore, body condition scoring depends on trained assessors and is subject to variability and subjectivity between evaluations. Advances in technology are enabling the assessment of body weight and condition score through imaging techniques, making the process faster, more accurate, and non-invasive [4].
Li and Thang [5] highlighted that digital image, combined with artificial intelligence tools such as deep learning, can be used to obtain morphometric data from cattle and goats. Zhang et al. [6] demonstrated a strong correlation between body size measurements from images and body weight in sheep, with body length being the most significant predictor. Additionally, Iqbal et al. [7] found that machine learning methods, specifically the Random Forest and Gradient Boosting Machine algorithms, provided higher accuracy with versatility in predicting body weight from goat body measurements.
However, research on developing technologies to predict the BW and BCS of dairy goats remains limited, highlighting the need for further studies to enhance the effectiveness of digital imaging applications. Therefore, this study aimed to evaluate the use of digital images and the random forest algorithm to predict BW and classify BCS in female dairy goats.

2. Materials and Methods

The study was conducted at the Federal University of Viçosa (UFV), located in the municipality of Viçosa, Minas Gerais, Brazil. The project was approved by the Ethics Committee for the Use of Production Animals (CEUAP; protocol 60/2023).
A total of 154 female goats of the Saanen (n = 77) and Alpine (n = 77) breeds were used, distributed across the following age categories: pre-weaning (n = 30, age 1–3 months), post-weaning (n = 24, age 4–14 months) and lactating/non-pregnant (primiparous and multiparous) (n = 100, age > 15 months). The animals were in an intensive system in collective free-stall stalls with access to the solarium (except for the pre-weaning animals, who were kept in suspended cages) and were equipped with a feeding trough, drinking trough (water ad libitum), salt trough, and sawdust floor covering.
For traditional measurements, all animals were weighed once using a fixed digital scale Toledo 2099 (São Bernardo do Campo, Brazil). For body condition score (BCS), only animals in the post-weaning and lactation phases (n = 124) were evaluated once by three trained evaluators through palpation of the lumbar region, paying specific attention to the spine, including the spinous and transverse processes using a five-point scale (1 to 5) with 0.5-point increments [8]. Simultaneously, one-minute two-dimensional (2D) video recordings of each animal were captured under natural lighting conditions using an Intel® RealSense™ D435 camera (Santa Clara, CA, USA) mounted on a professional tripod. Individual recordings were taken of three anatomical regions: the left side, front (sternum), and upper (rump). The camera was positioned at a fixed distance of 1.80 m from the animal and set at two heights from the ground: 67 cm for capturing the left side and front views, and 135 cm for the upper view (Figure 1).
After image collections, a single frame from each anatomical region was extracted using Intel Viewer software v2.55.1 version. The images, with a resolution of 640 × 480 pixels, were saved in PNG format and processed in ImageJ software 1.54g version. Measuring points were used to obtain morphometric features in pixels: withers height (WH), measured from the highest point of the scapula to the ground; rump height (RH), from the highest point of the rump to the ground; body length (BL), from the anterior shoulder to the point of tail insertion; chest depth (D), from the dorsal line to the deepest point of the thorax; paw height (PH), from the highest point of the front paw to the ground; chest width (CW), from the widest point of the chest to its corresponding opposite point; rump width (RW), at the widest point of the rump; and rump length (RL), from the most anterior to the most posterior point of the rump (Figure 2) [9]. Reference points from the environment were used in the recordings to convert pixel measurements into real-world values (cm).
A descriptive analysis was conducted to summarize the data. Pearson’s correlation was performed at a 5% significance level to assess the relationship between morphometric image features and body weight (BW). Correlations were classified as low (0.00–0.29), moderate (0.30–0.59), high (0.60–0.89), very high (0.90–0.99), and perfect (1.00) [10].
For BW prediction and BCS classification, the dataset was split into 70% for training and 30% for testing, considering the pre-weaning, post-weaning, and lactating/non-pregnant categories for BW, and low (1–2), moderate (2–3), and high (>3) categories for BCS, respectively.
Using morphometric image features, the random forest (RF) machine learning algorithm was optimized by grid search minimizing the root-mean-square error (RMSE) through cross-validation (5-folds) with training data. The importance of the variables calculated in the final model after optimization showed as percentage. The model precision and accuracy for body weight (BW) prediction with test dataset was evaluated using the coefficient of determination (R2), RMSE, and mean absolute error (MAE). For body condition score (BCS) prediction, model performance was evaluated using test data with the confusion matrix.

3. Results

3.1. Prediction of Body Weight

The correlations between body weight (BW) and the morphometric features obtained via imaging were significant (p < 0.05) and positive (Table 1). Body weight showed a high correlation with all the variables, exceeding 0.70.
The random forest model was precise (R2: 0.8749) and accuracy (MAE: 5.16 and RMSE: 7.13) to predict the body weight using seven morphometric features extracted from digital images of dairy goats (Figure 3A). Among the image-derived variables (Figure 3B), D was the most influential, explaining 22.14% of the variation in body weight prediction, followed by CW (18.93%), BL (15.47%), RH (13.44%), PH (12.79%), RW (9.08%), and RL (8.15%).

3.2. Classification of Body Score Condition

For BCS classification, the random forest model using eight morphometric features from digital images had an error rate of 0.5945 and an accuracy of 0.4054, with the diagonal of the confusion matrix representing the true positives (Figure 4A). The importance of each variable for BCS classification revealed that chest width (CW) made the greatest contribution (20.38%), followed by RH at 15.78%, RL at 12.63%, BL at 11.73%, RW at 10.74%, D at 10.53%, WH at 10.02%, and PH at 8.15% (Figure 4B).

4. Discussion

Positive and significant correlations were observed between all morphometric features extracted from the images and body weight. Among them, body length (BL), chest width (CW), and depth (D) exhibited the highest correlations with body weight (r > 0.90). This is since measurements such as height, depth, and chest width are closely related to the animal’s body volume, which is in turn strongly associated with body weight. Similarly, Çakmakçi et al. [11], who evaluated morphometric features for predicting the body weight of Norduz sheep using a random forest model, found that BL, D, and CW were the most strongly correlated variables, with correlations of 0.57, 0.77, and 0.72, respectively. For lactating Saanen goats, Pesmen and Yardimci [12] observed that BL and D showed a high correlation with BW (r > 0.70).
In this context, Sabry et al. [13] indicates that linear body measurements have the potential to accurately predict the body weight of Shami goats using linear regression models. In addition, Song et al. [14] demonstrated that morphometric features derived from digital images offer the advantage of predicting body weight, enabling continuous monitoring to assess the growth stage and development of the animals. In this study, the random forest model predicted the body weight of female goats with high precision (R2 = 0.87) using morphometric features derived from images. This result falls within the range reported by Pesmen and Yardimci [12], who found R2 values between 0.71 and 0.95 for predicting the body weight of dairy goats using morphometric measurements.
Consistent with the correlation results, the most influential variables in the random forest model were D, CW and BL. Çakmakçi et al. [11] also reported that D and CW accounted for a substantial portion of the variance, explaining 38.77% and 23.77%, respectively. Regarding the importance of morphometric traits, BL is an example of predictor of body weight. According to Rahman et al. [15], BL is closely associated with the development of skeletal and muscular systems, which contribute significantly to overall body mass. Moreover, Tyasi et al. [16] observed through simple linear regression that each 1 cm increase in BL corresponds to an approximate increase of 0.58 kg in the body weight of female goats.
Despite the high precision in predicting body weight using image-derived data, the model still exhibited some errors, as indicated by the MAE (5.16) and RMSE (7.13) values. These errors may be attributed to the natural activity level of goats, which can lead to motion-induced distortions in the images and affect the quality of the captured frames. Another contributing factor could be the length and density of the animals’ hair, as image-based measurements may reflect the outer hair surface rather than the actual body contour, potentially biasing the results [5]. Therefore, it is essential to continuously improve image quality and refine the selection of anatomical reference points to enhance prediction accuracy [14].
In the context of BCS prediction, it was revealed that goats with BCS 2 to 3 were better classified, likely due to the larger number of measurements available for this class. However, the overall results indicate that the model has limited ability to accurately classify the condition of these animals due to high error rates and low accuracy. For example, the Alvarez et al. [17] showed that a BCS of 4.5 for Holstein cows could not be classified due to the limited amount of data points available. Tememos et al. [18] reported a similar issue in their study of classifying body condition score (BCS) using digital images of the Greek local breed of dairy goats. They suggested reclassifying BCS as follows: BCS ≤ 2.5 as Thin, 2.5 < BCS ≤ 3.25 as Normal, and BCS > 3.25 as Fat. Their study demonstrated an improvement in prediction accuracy, achieving 0.9794 using a convolutional neural network (CNN) model.
In terms of the importance of each variable in predicting BCS, CW showed the greatest contribution to the model. This can be explained by the fact that, in goats, the greatest fat deposition is found in the sternal region rather than the back regions. These findings corroborate the study by Mendizabal et al. [19] where greater accuracy was observed in estimating the total fat of Blanca Celtibérica female goats using the BCS for the sternal region with an R2 of 0.90 compared to the BCS for the lumbar region with an R2 of 0.59.

5. Conclusions

It was possible to predict the body weight of dairy goats with high precision and accuracy using morphometric features extracted from digital images. However, the precision and accuracy of body condition score classification in female dairy goats were low, indicating that improvements in the image database or the extracted new features are necessary.

Author Contributions

Conceptualization, investigation, methodology, data curation, writing—original draft, visualization, supervision, M.A.G. Data curation, M.S.M.C. Writing—review and editing. C.R. Writing—review and editing, E.R.C. Writing—review and editing, L.N.R. Conceptualization, methodology, formal analysis, resources, data curation, writing—review and editing, E.B.S. All authors have read and agreed to the published version of the manuscript.

Funding

This research was funded by Coordenação de Aperfeiçoamento de Pessoal de Nível Superior grant number [32002017011P9].

Institutional Review Board Statement

The animal study protocol was approved by the Ethics Committee for the Use of Production Animals (CEUAP; protocol 60/2023).

Informed Consent Statement

Not applicable.

Data Availability Statement

The code can be requested from the corresponding authors. The data are not publicly available due to being part of an ongoing study and privacy.

Conflicts of Interest

The authors declare no conflicts of interest.

References

  1. Koyuncu, M.; Altinçekiç, Ş.Ö. Importance of body condition score in dairy goats. Maced. J. Anim. Sci. 2013, 3, 167–173. [Google Scholar] [CrossRef]
  2. Widiyono, I.; Sarmin, S.; Yanuartono, Y. Influence of body condition score on the metabolic and reproductive status of adult female Kacang goats. J. Appl. Anim. Res. 2020, 48, 201–206. [Google Scholar] [CrossRef]
  3. Martins, B.M.; Mendes, A.L.C.; Silva, L.F.; Moreira, T.R.; Costa, J.H.C.; Rotta, P.P.; Chizzotti, M.L.; Marcondes, M.I. Estimating body weight, body condition score, and type traits in dairy cows using three dimensional cameras and manual body measurements. Livest. Sci. 2020, 236, 104054. [Google Scholar] [CrossRef]
  4. Ma, W.; Qi, X.; Sun, Y.; Gao, R.; Ding, L.; Wang, R.; Peng, C.; Zhang, J.; Wu, J.; Xu, Z.; et al. Computer vision-based measurement techniques for livestock body dimension and weight: A review. Agriculture 2024, 14, 306. [Google Scholar] [CrossRef]
  5. Li, K.; Teng, G. Study on body size measurement method of goat and cattle under different backgrounds based on deep learning. Electronics 2022, 11, 993. [Google Scholar] [CrossRef]
  6. Zhang, A.L.; Wu, P.; Jiang, C.X.H.; Xuan, D.C.Z.; Ma, E.Y.H.; Zhang, F.Y.A. Development and validation of a visual image analysis for monitoring the body size of sheep. J. Appl. Anim. Res. 2018, 46, 1004–1015. [Google Scholar] [CrossRef]
  7. Iqbal, F.; Waheed, A.; Faraz, A. Comparing the predictive ability of machine learning methods in predicting the live body weight of Beetal goats of Pakistan. Pak. J. Zool. 2022, 54, 231–238. [Google Scholar] [CrossRef]
  8. Russel, A.J.F.; Doney, J.M.; Gunn, R.G. Subjective assessment of body fat in live sheep. J. Agric. Sci. 1969, 72, 451–454. [Google Scholar] [CrossRef]
  9. ADGA. Guidebook; American Dairy Goat Association: Spindale, NC, USA, 2022; Available online: https://adga.org/wp-content/uploads/2022/04/ADGA-Guidebook-2022-online-version.pdf (accessed on 20 January 2025).
  10. Callegari-Jacques, S.M. Bioestatística: Princípios e Aplicações; Artemed: Porto Alegre, Brazil, 2003; Available online: https://www.meulivro.biz/bioestatistica/3488/bioestatistica-principios-e-aplicacoes-1-ed-pdf (accessed on 20 January 2025).
  11. Çakmakçi, C. Live weight prediction in Norduz Sheep using machine learning algorithms. Turk. J. Agric.-Food Sci. Technol. 2022, 10, 587–594. [Google Scholar] [CrossRef]
  12. Pesmen, G.; Yardimci, M. Estimating the live weight using some body measurements in Saanen goats. Arch. Zootech. 2008, 11, 30–40. [Google Scholar]
  13. Sabry, A.; Rahman, A.E.; Shoukry, M.M.; Mohamed, M.I.; Salman, F.M.; Abedo, A.A. Somebody measurements as a management tool for Shami goats raised in subtropical areas in Egypt. Bull. Natl. Res. Cent. 2019, 43, 17. [Google Scholar] [CrossRef]
  14. Song, X.; Bokkers, E.A.M.; Van der Tol, P.P.J.; Koerkamp, P.G.; Van Mourik, S. Automated body weight prediction of dairy cows using 3-dimensional vision. J. Dairy Sci. 2018, 101, 4448–4459. [Google Scholar] [CrossRef] [PubMed]
  15. Rahman, A.S.; Khandoker, M.A.M.Y.; Husain, S.S.; Apu, A.S.; Mondal, A.; Notter, D.R. Morphometric characterization and relationship of body weight with linear body measurements in Black Bengal buck. Bangladesh J. Anim. Sci. 2008, 37, 8–16. [Google Scholar] [CrossRef]
  16. Tyasi, T.L.; Mathapo, M.C.; Mokoena, K.; Maluleke, D.; Rashijane, L.T.; Makgowo, K.M.; Danguru, L.W.; Molabe, K.M.; Bopape, P.M.; Mathye, N.D. Assessment of the relationship between body weight and morphological traits of South African nondescript indigenous goats. J. Anim. Health Prod. 2020, 8, 32–39. [Google Scholar] [CrossRef]
  17. Alvarez, J.R.; Arroqui, M.; Mangudo, P.; Toloza, J.; Jatip, D.; Rodríguez, J.M.; Teyseyre, A.; Sanz, C.; Zunino, A.; Machado, C.; et al. Body condition estimation on cows from depth images using Convolutional Neural Networks. Comput. Electron. Agric. 2018, 155, 12–22. [Google Scholar] [CrossRef]
  18. Temenos, A.; Voulodimos, A.; Korelidou, V.; Gelasakis, A.; Kalogeras, D.; Doulamis, A.; Doulamis, N. Goat-CNN: A lightweight convolutional neural network for pose-independent body condition score estimation in goats. J. Agric. Food Res. 2024, 16, 101174. [Google Scholar] [CrossRef]
  19. Mendizabal, J.A.; Dela, R.; Arana, A.; Purroy, A. A comparison of different pre- and post-slaughter measurements for estimating fat reserves in Spanish Blanca Celtiberica goats. Can. J. Anim. Sci. 2010, 90, 437–444. [Google Scholar] [CrossRef]
Figure 1. Methodological framework for measuring and collecting images of dairy goats.
Figure 1. Methodological framework for measuring and collecting images of dairy goats.
Animals 15 01449 g001
Figure 2. Morphometrics features for dairy goats. WH = withers height; RH = rump height; RW = rump width; RL = rump length; BL = body length; D = chest depth; CW = chest width; PH = paw height.
Figure 2. Morphometrics features for dairy goats. WH = withers height; RH = rump height; RW = rump width; RL = rump length; BL = body length; D = chest depth; CW = chest width; PH = paw height.
Animals 15 01449 g002
Figure 3. (A) Regression of observed weight (body weight) on predicted weight in dairy goats and (B) percentage of importance of variables extracted from digital images for body weight prediction. R2: coefficient of determination; MAE: mean absolute error; RMSE: root mean square error; BL: body length; D: chest depth; CW: chest width; RH: rump height; PH: paw height; RW: rump width; RL: rump length.
Figure 3. (A) Regression of observed weight (body weight) on predicted weight in dairy goats and (B) percentage of importance of variables extracted from digital images for body weight prediction. R2: coefficient of determination; MAE: mean absolute error; RMSE: root mean square error; BL: body length; D: chest depth; CW: chest width; RH: rump height; PH: paw height; RW: rump width; RL: rump length.
Animals 15 01449 g003
Figure 4. (A) Confusion matrix of the test set and (B) percentage of importance of variables extracted from digital images for body condition score classification in dairy goats. n = number of observations within each class. BCS: body condition score; WH: withers height; RH: rump height; RW: rump width; RL: rump length; BL: body length; D: chest depth; CW: chest width; PH: paw height.
Figure 4. (A) Confusion matrix of the test set and (B) percentage of importance of variables extracted from digital images for body condition score classification in dairy goats. n = number of observations within each class. BCS: body condition score; WH: withers height; RH: rump height; RW: rump width; RL: rump length; BL: body length; D: chest depth; CW: chest width; PH: paw height.
Animals 15 01449 g004
Table 1. Summary of the database and correlation of BW for the image features evaluated in dairy goats.
Table 1. Summary of the database and correlation of BW for the image features evaluated in dairy goats.
VariableMeanSDMinMaxr
 Body weight, kg39.7920.474.9080.00
 BCS2.720.761.004.50
Image measurements (cm)
 Withers Height78.7117.0937.23101.480.86
 Rump Height80.6317.5138.20102.190.86
 Rump Width21.405.777.7730.930.85
 Rump Length25.846.847.8440.030.72
 Body Length77.6918.2535.30109.390.92
 Chest Depth37.678.8117.2455.050.91
 Chest Width23.515.1812.6334.770.92
 Paw Height42.579.3718.4654.990.79
SD: Standard deviation, Min: minimum; Max: maximum; BCS: body condition score; r: Pearson correlation with Body Weight.
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Gonçalves, M.A.; Castro, M.S.M.; Carrara, E.R.; Raineri, C.; Rennó, L.N.; Schultz, E.B. Prediction of Weight and Body Condition Score of Dairy Goats Using Random Forest Algorithm and Digital Imaging Data. Animals 2025, 15, 1449. https://doi.org/10.3390/ani15101449

AMA Style

Gonçalves MA, Castro MSM, Carrara ER, Raineri C, Rennó LN, Schultz EB. Prediction of Weight and Body Condition Score of Dairy Goats Using Random Forest Algorithm and Digital Imaging Data. Animals. 2025; 15(10):1449. https://doi.org/10.3390/ani15101449

Chicago/Turabian Style

Gonçalves, Mateus Alves, Maria Samires Martins Castro, Eula Regina Carrara, Camila Raineri, Luciana Navajas Rennó, and Erica Beatriz Schultz. 2025. "Prediction of Weight and Body Condition Score of Dairy Goats Using Random Forest Algorithm and Digital Imaging Data" Animals 15, no. 10: 1449. https://doi.org/10.3390/ani15101449

APA Style

Gonçalves, M. A., Castro, M. S. M., Carrara, E. R., Raineri, C., Rennó, L. N., & Schultz, E. B. (2025). Prediction of Weight and Body Condition Score of Dairy Goats Using Random Forest Algorithm and Digital Imaging Data. Animals, 15(10), 1449. https://doi.org/10.3390/ani15101449

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop