Automatic livestock monitoring to identify abnormal
behavior on the Balcashi ranch, Chimborazo Province
Monitoreo automático de
ganado para identificar comportamientos anormales en la hacienda balcashi
Provincia del Chimborazo
Published Edwards Deming Higher
Technological Institute. Quito -
Ecuador Periodicity October
- December Vol.
1, No. 27, 2025 pp. 1-9 http://centrosuragraria.com/index.php/revista Dates of receipt Received: April 12, 2025 Approved: June 30, 2025 Correspondence author Creative Commons License Creative Commons License,
Attribution-NonCommercial-ShareAlike 4.0
International.https://creativecommons.org/licenses/by-nc-sa/4.0/deed.es
Byron Oviedo-Bayas1
Cristian G. Zambrano-Vega2
Professor at the Technical
State University of Quevedo, Graduate School,boviedo@uteq.edu.ec , https://orcid.org/0000-0002-5366-5917 Professor at the Quevedo State Technical University, Ecuador,czambrano@uteq.edu.ec , https://orcid.org/0000-0001-8568-8024
Keywords:
Precision livestock
farming, machine learning, animal welfare, heat stress.
Docente
de la Universidad Técnica Estatal de Quevedo, Facultad de Posgrado, boviedo@uteq.edu.ec, https://orcid.org/0000-0002-5366-5917 Docente
de la Universidad Técnica Estatal de
Quevedo, Ecuador, czambrano@uteq.edu.ec, https://orcid.org/0000-0001-8568-8024
Palabras clave: Ganadería de precisión, aprendizaje automático, bienestar animal, estrés térmico.
Introduction
Livestock
farming is one of the main economic activities globally, playing an essential
role in food security, job creation, and the development of rural economies
(Santana et al., 2025). In particular, cattle farming faces various challenges,
including the early detection of abnormal behaviors that could indicate health,
welfare, or productivity problems. Behaviors such as lameness, social
isolation, or irregular feeding patterns can be signs of disease, pain, or
stress conditions, and their timely identification is key to mitigating risks,
reducing economic losses, and improving animal welfare (Senanayake et al.,
2024; Kaur & Virk, 2025).
Traditionally,
livestock monitoring has been based on direct observation by field workers or
veterinarians, which introduces factors of subjectivity, human fatigue, and
lack of continuity, especially in geographically complex environments such as
the Ecuadorian Sierra. The Balcashi Ranch, located in
the province of Chimborazo (Ecuador), represents a typical scenario of these
limitations, where the Andean climate, extensive grazing conditions, and the
racial diversity of livestock make it difficult to implement traditional health
and production control systems.
Faced
with this problem, the incorporation of emerging technologies has opened up new
possibilities for transforming traditional livestock farming into more
intelligent and sustainable systems. Among these technologies are environmental
and motion sensors, the Internet of Things (IoT), and, in particular,
artificial intelligence (AI) techniques, which allow large volumes of data to
be analyzed in real time to detect patterns and anomalies (Wang et al., 2023;
Farooq et al., 2022; Khan et al., 2024).
Several
recent studies have demonstrated the effectiveness of machine learning in
classifying normal and abnormal behavior in cattle based on data collected by
inertial sensors, accelerometers, and smart collars (Russel & Selvaraj,
2024; Guarda-Vera & Muñoz-Poblete, 2025). For example, Hollevoet
et al. (2024) were able to identify stress and disease behaviors in goats by
analyzing accelerometer data, and Tian et al. (2024) developed a predictive
system for mastitis in dairy cows by integrating data on rumination, milk
production, and electrical conductivity. These applications highlight the
potential of AI to reduce dependence on human monitoring and optimize
decision-making.
This
research proposes the design and implementation of an automated monitoring
system adapted to the conditions of Hacienda Balcashi,
integrating climate sensors for temperature, humidity, precipitation, and
behavior sensors such as accelerometers with machine learning algorithms. It
starts with the analysis of historical data collected between 2019 and 2024,
and applies a quantitative, h y methodology to evaluate the relationship
between climate variables, animal breed, and the frequency of abnormal behaviors.
This
work is distinguished by its contextualized approach to high-altitude livestock
farming and its potential scalability to other farms with similar
characteristics. In addition, it provides a methodological basis that can be
expanded in future studies to include elements such as audio sensors (Gavojdian et al., 2024), blockchain for traceability
(Mansour, 2022), or advanced IoT systems (Kaur & Virk, 2025). This
contributes to closing the technological gap in rural regions and promotes more
efficient, ethical, and climate-resilient livestock farming.
Methodology
This
research adopts a quantitative, observational, and analytical approach designed
to understand the relationship between climate variables, individual livestock
characteristics, and the manifestation of abnormal behaviors. The study was
conducted at Hacienda Balcashi, located in the province of Chimborazo
(Ecuador), based on a set of historical data collected between 2019 and 2024.
The
main database was an Excel file
("Balcashi_Livestock_2019-2024.xlsx"), containing daily records of
climatic variables such as temperature °C, relative humidity %, precipitation
mm, and livestock behavior, where behaviors are coded as "normal" if
they are grazing or resting and "abnormal" if they are lame or
isolated. Each record includes individual animal identification, breed
(Criollo, Jersey, Holstein), date, and location.
The
independent variables were temperature, humidity, precipitation, and breed. The
main dependent variable was the type of behavior (normal or abnormal), and
secondarily, the specific type of abnormality detected.
Procedure
and data preprocessing
A
retrospective longitudinal analysis methodology was applied, considering
repeated measurements per animal over time. Preprocessing included data
cleaning by removing duplicates and re ting missing values, detecting outliers
using the interquartile range (IQR), coding categorical variables, and
normalizing numerical variables.
Statistical
modeling and validation
Statistical
analysis began with an Exploratory Data Analysis (EDA) to identify preliminary
patterns and relationships between variables. Subsequently, Pearson and
Spearman correlation tests were used to evaluate the association between
climate variables and the frequency of abnormal behaviors.
Logistic
regression was applied for predictive modeling, training the model with 70% of
the data and validating it with the remaining 30%. Evaluation metrics included
accuracy, precision, recall, and area under the ROC curve (AUC). Additionally,
mixed models (random effects) were used to control for individual variability
per animal, and ANOVA was used to evaluate differences by breed.
Infrastructure
and tools
Data
analysis was performed in Python (v3.9), using libraries such as Pandas, NumPy,
Scikit-learn, and Statsmodels. Data were visualized with Matplotlib and
Seaborn. Jupyter Notebook was used as the development environment.
Ethical
considerations
Although
this is a retrospective study based on existing data, the confidentiality of
the information and the welfare of the animals were guaranteed. Field
observations were made without altering the animals' routines or inducing
stressful situations.
Results
Relationship
between climatic variables and abnormal behavior
Correlation
between climatic variables and abnormal behaviors
To
assess the relationship between climatic conditions and abnormal livestock
behavior, data on climatic and behavioral variables recorded between 2019 and
2024 were extracted and normalized. Pearson's correlation coefficient was used
to quantify the associations between the variables.
Table
1: Correlation
between climate variables and abnormal behavior
|
Variable |
Coefficient
(r) |
p-value |
|
Temperature |
0.45 |
<0.01 |
|
Humidity |
0.32 |
<0.05 |
|
Precipitation |
0.12 |
>0.1 |
The
results indicated a moderate positive correlation between temperature and the
frequency of abnormal behaviors (r = 0.45, p < 0.01), and a smaller but
significant association with humidity (r = 0.32, p < 0.05). Precipitation
was not significantly correlated (r = 0.12, p > 0.1), suggesting that heat
stress plays a more important role than rainfall in this context. This implies
that rising temperatures, possibly associated with climate change, could become
a key trigger of animal distress at high altitudes.
Frequency
of abnormal behavior by breed
To
determine whether there are differences in susceptibility to abnormal behavior
between breeds, the data were grouped by breed and a one-factor ANOVA was
applied. In addition, mixed models were used to control for individual
variability of each animal in repeated measurements.
Table
2: Frequency of
abnormal behaviors by breed
|
Breed |
Mean
(events/day) |
Standard
deviation |
|
Holstein |
1.2 |
0.3 |
|
Jersey |
0.8 |
0.2 |
|
Creole |
0.5 |
0.1 |
The
analysis revealed statistically significant differences (F(2,147) = 5.67, p
< 0.01). The Holstein breed had the highest incidence of abnormalities (1.2
events/day), followed by Jersey (0.8) and Criollo (0.5). This difference can be
interpreted from the perspective of environmental adaptability: foreign breeds
such as Holstein, developed in temperate climates, tend to show greater
physiological sensitivity to heat stress and altitude hypoxia. The lower level
of events in Criollo reinforces their adaptive genetic value, opening the
discussion on their inclusion in resilient genetic improvement programs.
Logistic
regression model performance
A logistic regression model was trained with 70% of the dataset to predict the occurrence of abnormal behaviors based on climatic variables and breed. Validation was performed with the remaining 30%.
Table 3: Classification model metrics
|
Metric |
Value (%) |
Confidence
interval (95%) |
|
Accuracy |
82 |
79-85 |
|
Precision |
78 |
74-81 |
|
Recall |
75 |
71-79 |
|
AUC-ROC |
0.84 |
0.81-0.87 |
The
model achieved an accuracy of 82%, a precision of 78%, a recall of 75%, and an
AUC-ROC of 0.84. This performance validates its applicability in real-world
scenarios with a low margin of error, allowing corrective decisions to be made
before severe clinical or economic consequences occur.
In
terms of robustness, it is in line with studies such as that by Russel &
Selvaraj (2024). However, effectiveness will also depend on the operating
threshold and the frequency of retraining in changing environments, which
should be considered for large-scale implementation.
The
findings show that climate variables and breed are significant predictors of
abnormal behavior in Balcashi cattle. The proposed
model offers a viable tool for early detection, although its scalability
requires adjustments for other regions, as suggested by Farooq et al. (2022).
Conclusions
The
authors showed that it was possible to implement an automatic monitoring system
for abnormal behavior in cattle at the Balcashi
Ranch, including climate variables and characteristics of the cattle
themselves. The findings indicated that temperature and humidity had a
significant relationship with the emergence of anomalies (r = 0.45 and r =
0.32), which corroborates the literature on heat stress and its effect on
animal welfare (Senanayake et al., 2024; Kaur & Virk, 2025). They also
found notable differences between breeds, with Holstein showing greater
susceptibility to abnormal behavior (1.2 events/day), followed by Jersey (0.8)
and Criollo (0.5), which highlights the adaptive importance of climate (Gavojdian et al., 2024; Qiao et al., 2021).
The
performance of the logistic regression model was robust, with an accuracy of
82% and an AUC-ROC of 0.84, confirming its effectiveness for early detection of
injuries or functional anatomical problems. Its performance, although lower
than that reported by Wang et al. (2023), could be explained by the wide
variety of conditions present in the Ecuadorian highlands. The incorporation of
environmental sensors and accelerometers together with automatic learning
methods is in line with the latest global advances in precision livestock
farming (Santana et al., 2025; Russel & Selvaraj, 2024).
This
work provides a scalable methodological framework for high Andean farms,
promoting animal welfare and sustainability, although its implementation
requires local adaptations, as noted by Farooq et al. (2022). The automation of
livestock monitoring represents a key step toward more efficient and ethical
production.
References
Farooq, M. S.,
Sohail, O. O., Abid, A., & Rasheed, S. (2022). A survey on the role of IoT
in agriculture for the implementation of smart livestock environments. IEEE
Access, 10, 9483-9505.
Gavojdian, D., Mincu,
M., Lazebnik, T., Oren, A., Nicolae, I., & Zamansky, A. (2024).
BovineTalk: machine learning for vocalization analysis of dairy cattle under
the negative affective state of isolation. Frontiers in Veterinary Science,
11, 1357109.
Guarda-Vera, M.,
& Muñoz-Poblete, C. (2025). Preliminary Development of a Database for
Detecting Active Mounting Behaviors Using Signals Acquired from IoT Collars in
Free-Grazing Cattle. Sensors, 25(10), 3233.
Hollevoet, A., De
Waele, T., Peralta, D., Tuyttens, F., De Poorter, E., & Shahid, A. (2024).
Goats on the Move: Evaluating Machine Learning Models for Goat Activity
Analysis Using Accelerometer Data. Animals, 14(13), 1977.
Islam, M. N., Yoder,
J., Nasiri, A., Burns, R. T., & Gan, H. (2023). Analysis of the drinking
behavior of beef cattle using computer vision. Animals, 13(18), 2984.
Kaur, D., & Virk,
A. K. (2025). Smart neck collar: IoT-based disease detection and health
monitoring for dairy cows. Discover Internet of Things, 5(1),
12.
Khan, S., Mazhar, T.,
Shahzad, T., Khan, M. A., Guizani, S., & Hamam, H. (2024). Future of
sustainable farming: exploring opportunities and overcoming barriers in
drone-IoT integration. Discover Sustainability, 5(1), 1-22.
Mansour, R. F.
(2022). Blockchain assisted clustering with intrusion detection system for
industrial internet of things environment. Expert Systems with Applications,
207, 117995.
Neethirajan, S.,
& Kemp, B. (2021). Social network analysis in farm animals: Sensor-based
approaches. Animals, 11(2), 434.
Qiao, Y., Kong, H.,
Clark, C., Lomax, S., Su, D., Eiffert, S., & Sukkarieh, S. (2021).
Intelligent perception-based cattle lameness detection and behavior
recognition: A review. Animals, 11(11), 3033.
Russel, N. S., &
Selvaraj, A. (2024). Decoding cow behavior patterns from accelerometer data
using deep learning. Journal of Veterinary Behavior, 74, 68-78.
Santana, T. C.,
Guiselini, C., Pandorfi, H., Vigoderis, R. B., Barbosa Filho, J. A. D.,
Soares, R. G. F., ... & Santos, P. C. D. S. (2025). Ethics, Animal
Welfare, and Artificial Intelligence in Livestock: A Bibliometric Review. AgriEngineering,
7(7), 202.
Senanayake, S. C.,
Liyanage, P., Pathirage, D. R., Siraj, M. R., De Silva, B. N. K., &
Karunaweera, N. D. (2024). Impact of climate and land use on the temporal
variability of sand fly density in Sri Lanka: A 2-year longitudinal study. PLOS
Neglected Tropical Diseases, 18(11), e0012675.
Tian, H., Zhou, X.,
Wang, H., Xu, C., Zhao, Z., Xu, W., & Deng, Z. (2024). The prediction of
clinical mastitis in dairy cows based on milk yield, rumination time, and milk
electrical conductivity using machine learning algorithms. Animals,
14(3), 427.
Wang, Y., Li, Q., Chu, M., Kang,
X., & Liu, G. (2023). Application of infrared thermography and machine
learning techniques in cattle health assessments: A review. Biosystems
Engineering, 230, 361-387.