S. Rostami, S. Rostami, J. Shayegh
Abstract
Mastitis is one of the major health and welfare problems affecting dairy cattle. It is one of the diseases that has a significant economic impact on the dairy industry. This paper proposes an innovative artificial intelligence approach for predicting the risk of mastitis in cattle. The goal of the study is to develop a reliable, low-cost AI-based system designed to enable early detection of mastitis, particularly benefiting small farms. Small dairy farms often have limited financial and technical resources and may lack access to advanced diagnostic technologies. Therefore, this study focuses on developing a low-cost, AI-based mastitis detection system that can be easily implemented using existing sensor data, making it particularly suitable and beneficial for small-scale farming operations. The system employs a data-driven methodology, collecting data from cattle to train machine learning algorithms. The system was designed to predict the risk of mastitis at an early stage. The dataset used includes comprehensive information on mastitis in cattle, ensuring the system's predictions are both accurate and relevant. The proposed method uses several real-time sensors, including low-cost flex and temperature sensors, to collect data. The system employed the flex sensor, a resistive bend sensor that changes its electrical resistance based on how much it bends, to monitor movement-related patterns. The temperature measurements were obtained using the Digital Temperature Sensor, a thermistor-based digital sensor capable of providing real-time surface temperature readings with high sensitivity and stability (±0.5°C accuracy). These sensors are widely available and commonly used in the market due to their low cost, reliability, and ease of integration. This approach is based on a dataset of 6600 records, comprising data from 1100 cows over 6 days. To address mastitis, an Explainable Artificial Intelligence (XAI)-based classification technique was proposed using sensor data (such as temperature, milk conductivity, rumination activity, and environmental conditions). The proposed XAI model predicted the risk of mastitis by analyzing early infection. Then, the XAI method achieved an accuracy of 97.89%, outperforming the other evaluated machine-learning models (Conventional Neural Network, Support Vector Machine, Random Forest, k-Nearest Neighbors, Deep Learning, and Self-Supervised). Among all models, XAI showed the highest precision, recall, and F1-score, indicating superior reliability in recognizing healthy cows from mastitis-infected cows. These results showed that the XAI method not only provided accurate predictions but also offered transparent explanations of its decisions, which can support farmers and veterinarians in making informed and timely interventions.
Citation format
ROSTAMI, S.; ROSTAMI, S.; SHAYEGH, J. Mastitis prediction by explainable artificial intelligence learning at the initial phase of infection in dairy cows. Journal of Applied Veterinary Sciences, 2026.