#Industry Bioenergy Energy efficiency

Machine learning and milk analyses make it easier to monitor cow and herd health

The use of technologies, including machine learning in measuring milk components of individual cows may ensure early detection of diseases and maximization of individual cow and herd potential.

 Overview of the use of ML, milk samples, and FTIR on the dairy farm. The FTIR is used to collect and analyse data on various milk components of individual cows. The ML algorithms interpret the data and create predictions that are transmitted to the farmer to aid decision-making.

Better animal health and economic benefit

By using technologies such as sensors, machine learning (ML) algorithms, and Fourier transform infrared spectroscopy (FTIR) it is possible to collect and analyse data on various milk components of individual cows. FTIR spectroscopy is a widely used technique for analysing fat, protein, lactose, and urea content in cows. More recent also single fatty acids, other chemical components and immune cells have been identified by spectroscopy of cows milk.

These data can be used for early warning of diseases or other health issues in the dairy cow, such as mastitis, which can affect milk quality and quantity. ML algorithms can be used to develop predictive models that can forecast the likelihood of dissemination of diseases in the cow barn or identify individual cows that are at higher risk of developing health problems.

In this work, FTIR and ML approaches were used for the purpose of detecting and quantifying milk components associated with subclinical (invisible) ketosis during cows’ lactation. Subclinical ketosis is a metabolic disorder that affects dairy cows that are not able to cover their need of nutrients due to high milk production. Subclinical ketosis can result in reduced milk yield (MY), decreased fertility, and increased risk of other health problems. Consequently, it is an economically important disease in dairy farming worldwide. Early detection of cows with subclinical ketosis enables the farmer to intervene early and avoid reduced cow health, welfare, and financial loss. Herds with recurrent problems need to enhance the feeding of cows during the transition period around calving to ensure adequate  nutrition and management.

Furthermore, the use of ML in the dairy industry can also help farmers optimize milk production and reduce costs. By analysing data on individual cow milk components, ML algorithms can provide insights into the best feeding and management practices for each cow, resulting in higher milk yields, improved welfare and better overall herd performance.

The use of technologies, including ML, has the potential to revolutionize the dairy industry by providing farmers with real-time, accurate data on the milk components of individual cows, enabling them to make informed decisions and maximize their profitability while ensuring the welfare and health of their animals.

Big data production and FTIR analysis

In this work, production data were collected from the research dairy herd at the Animal Production Experimental Centre (SHF) at NMBU between September 2016 and February 2017. The experiment followed laws and regulations for animal experiments in Norway and was approved by the Norwegian Animal Research Authority. In total 64 Norwegian Red cows were followed from one week before calving until 100 days in milk (DIM). The cows were milked with an automatic milking system (AMS). Milk yield (MY) was recorded for each milking and summed to obtain daily yield. For all cows, milk samples were collected thrice weekly. The chemical composition of the milk samples provided by TINE was obtained as a reference for the subsequent exploration of dry-film FTIR milk analysis. The concentration of β-hydroxybutyrate (BHB) in blood was measured by a reference laboratory and used as gold standard to identify cows with subclinical ketosis.

By analysing the FTIR spectra of milk samples from individual cows, ML algorithms can predict the likelihood of subclinical ketosis in each cow and identify those that require closer monitoring and potential treatment. Additionally, this data can be used to adjust feeding and management practices to reduce the risk of subclinical ketosis in the herd.

The use of FTIR spectra of milk samples and machine learning has the potential to provide a non-invasive and cost-effective method for identifying subclinical ketosis and nutritional imbalances in high producing dairy cows, enabling farmers to take action to improve cow health, welfare and maximize milk production.

Machine Learning saves a lot of work

Analysis of big data by machine learning offers considerable advantages for the assimilation and evaluation of large amounts of complex health data. However, to effectively use machine learning tools in the early detection of disease, advanced data analysis must be performed before a useful output is possible. The advantages of machine learning include flexibility and scalability compared with traditional biostatistical methods. Another advantage of ML algorithms is the ability to analyse diverse data types and incorporate them into predictions for disease risks. They can be used to identify patterns and trends in the data, allowing farmers to detect health issues early on and take corrective actions.

For example, changes in milk composition can be an early sign of health problems in cows, such as mastitis or ketosis. By analyzing the milk samples, ML algorithms can detect these changes and alert farmers. This allows for proactive steps to treat cows before the condition worsens and to prevent the spread of infectious diseases such as mastitis.

Additionally, ML can be used to identify which cows are at the highest risk for developing health issues. By analysing historical data and risk factors pertaining to the single cow, ML algorithms can identify patterns that are associated with certain health conditions. This information can be used to develop targeted health interventions for individual cows, such as adjusting their diet or providing specific medications.

In unsupervised ML, the algorithm is tasked with finding patterns or relationships in the data without any specific guidance or labelled examples. In the case of investigating if the FTIR spectra of milk samples could be used to detect any systematic change in milk composition, an unsupervised learning algorithm could be used to cluster the spectra based on similarities or differences in the chemical composition of the milk samples. This could help identify systematic changes in the milk composition that are not immediately visible.

In supervised ML, the algorithm is trained on labelled data to make predictions or classifications on new data. In the case of predicting the fatty acid (FA) composition of milk samples, a supervised learning algorithm could be trained on a dataset of milk samples with known FA compositions to predict the FA composition of new milk samples. This could help to identify systematic changes in the predicted FA composition of milk samples over time, allowing dairy farmers and processors to make informed decisions about animal health issues and the quality and composition of raw milk.

Animal models may also pose excellent opportunities to develop and train ML-algorithms for, prevention, detection and treatments in human medicine.

Effectiveness of ML and FTIR of milk samples

The results [1] showed the detection of systematic changes in the chemical composition of cow milk during lactation by using PCA of the FTIR spectra. It illustrates the feasibility of using FTIR spectroscopy to characterize and quantify milk components during the lactation period of cows. The results reveal that systematic changes related to both gross milk composition and fatty acid features can be seen throughout lactation.

The PLSR approach used for the prediction of milk components showed systematic changes during lactation for the predicted FA composition. Differences in the predicted FA composition between cows with subclinical ketosis and normal cows were observed. It illustrates that ML and FTIR predictions of fatty acids early in the lactation period can potentially be used to predict cows diagnosed with subclinical ketosis later in the lactation period.


  1. Rachah, Amira, et al. “Exploring dry-film FTIR spectroscopy to characterize milk composition andsubclinical ketosis throughout a cow’s lactation.” Foods 10.9 (2021): 2033.

0 comments on “Machine learning and milk analyses make it easier to monitor cow and herd health

Leave a Reply

Your email address will not be published. Required fields are marked *