Artificial Intelligence Applied to a Robotic Dairy Farm to Model Milk Productivity and Quality based on Cow Data and Daily Environmental Parameters

Increased global temperatures and climatic anomalies, such as heatwaves, as a product of climate change, are impacting the heat stress levels of farm animals. These impacts could have detrimental effects on the milk quality and productivity of dairy cows. This research used four years of data from a robotic dairy farm from 36 cows with similar heat tolerance (Model 1), and all 312 cows from the farm (Model 2). These data consisted of programmed concentrate feed and weight combined with weather parameters to develop supervised machine learning fitting models to predict milk yield, fat and protein content, and actual cow concentrate feed intake. Results showed highly accurate models, which were developed for cows with a similar genetic heat tolerance (Model 1: n = 116, 456; R = 0.87; slope = 0.76) and for all cows (Model 2: n = 665, 836; R = 0.86; slope = 0.74). Furthermore, an artificial intelligence (AI) system was proposed to increase or maintain a targeted level of milk quality by reducing heat stress that could be applied to a conventional dairy farm with minimal technology addition.


Introduction
Robotic dairy farms or Automated Milking Systems (AMS) are the result of the implementation of state of the art technology related to robotics to increase milk yield through increased efficiency and automation [1,2]. These technologies are developed in response to the increasing market opportunities for the dairy industry globally, which is projected to grow by 35% by 2030 [3]. However, global demands will also be accompanied by 14 million traditional dairy farms shutting down production due to increased competitiveness and requirements for guaranteed milk quality and animal welfare [4]. The latter is considered a growing concern for consumers, which is achieved by AMS since it is based on the "milking when they like" system increasing wellbeing and welfare of cows [5]. Further potential advances to AMS technologies have been researched in recent years through the implementation of biometrics monitoring of animals to assess physiological changes in production systems [6]. Some of these technologies are noninvasive using visible (RGB) imagery/video, and infrared thermal imagery for heart rate, respiration rate, and body temperature assessments. These technologies could result in improvements in the monitoring of heat stress in farm animals.

Site, Robotic Dairy Farm, and Data Acquisition
The study was conducted in a dairy farm located at The University of Melbourne Dookie College, Victoria, Australia (36 • 22'48" S, 145 • 42'36" E). This region had an average annual rainfall of 537 mm (monthly extremes: 30.5-57.6 mm) and mean daily solar exposure of 17 MJ m 2 −1 (extremes: 7.3-27.3 m 2 −1 ) from 1991-2019; data obtained from the Bureau of Meteorology (BoM) Dookie Agricultural College station 081013. The farm consists of 43 ha of irrigated pastures based on perennial ryegrass (Lolium perenne) and annual ryegrass (Lolium multiflorum). The herd in this site consists of Holstein-Friesian cows. The farm contains three Lely Astronaut robotic milking machines (Lely Holding S.à.r.l., Maassluis, The Netherlands), with a capacity of 60 cows per machine (maximum capacity of 180 cows) that move voluntarily for milking. As described by Dunshea et al. [14], cows wear an identification transponder neck collar (Lely Holding S.à.r.l., Maassluis, The Netherlands), which records the cows' activity. The robotic milking system can automatically record parameters such as lactation days counted from day 0 at calving up to the time of next calving including the dry cow period, lactation number, milking frequency per day, milk yield (kg day −1 ), milk protein (%), milk fat (%) and somatic cells, programmed concentrate feed (kg day −1 ), concentrate feed intake (kg day −1 ), and liveweight (kg). Records of these data from June 2016 to March 2019 were used for this study.

Statistical Data and Machine Learning Modeling
Mean values of THI calculated with Equation (10) along with milk yield, milk protein, and fat content, and concentrate feed intake were obtained and plotted to visualize the effects of the different seasons on each parameter. Statistical data obtained from the inputs and targets consisted of minimum, maximum, and mean values of each parameter.
Two ML models were developed based on artificial neural networks (ANN) using the Bayesian Regularization training algorithm. The latter was chosen as it showed the best accuracy and performance as well as no over or underfitting [17] after testing 17 different algorithms using a customized code written in MATLAB®R2020a. The inputs for the models ( Figure 1) were based on the maximum values per day of the weather data (i) T, (ii) RH, (iii) rainfall, (iv) wind speed, (v) wind direction, (vi) T dp , (vii) T wet , (viii-xvi) THI calculated with the nine equations, and some data obtained from the robotic milking system, (xvii) programmed concentrate feed, (xviii) lactation days, (xix) lactation number, (xx) milking frequency, and (xxi) liveweight. The targets were also obtained from the robotic milking system. They consisted of (i) milk yield, (ii) milk protein, (iii) milk fat, and (iv) concentrate feed intake (i.e., cereal grain-based pellets fed to cows during milking, making up approximately 40% of cows diet). All data were normalized from −1 to 1. Model 1 was constructed using the data of cows with a similar heat tolerance (N = 36; heat tolerance range: 93-112) determined by estimation of Australian genomic breeding values for heat tolerance [18] following genotyping of each cow using hair follicle samples as per the commercial procedure (CLARIFIDE for dairy, Zoetis Australia Pty Ltd, Banyo, QLD, Australia). The genotyping experiment was approved by the University of Melbourne Faculty of Veterinary and Agricultural Science (FVAS) Animal Ethics Committee (AEC ID 1814645.1). In general, for heat stress, cows with Australian breeding values < 100 are less tolerant to hot, humid conditions than the average, while the cows with values > 100 are more tolerant than the average. Specifically, cows with breeding values of 93 will be 7% less heat tolerant than an average cow, and a cow with heat tolerance breeding values of 110 would be 10% more heat tolerant as compared to an average cow. In contrast, Model 2 was developed using data from all cows (N = 312) independent of their heat Sensors 2020, 20, 2975 4 of 11 tolerance to create a general model. Samples were divided randomly as 70% for training and 30% for testing using a default derivative function. Ten neurons were chosen as the best number giving the highest accuracy and best performance based on the means squared error (MSE).    Mean values per season of each year for temperature-humidity index (THI9) and the four parameters used as targets in the machine learning (ML) models to represent the effect of different weather patterns on potential heat stress, milk productivity, and quality. Table 1 shows the minimum, maximum, and mean values per year of each parameter used as inputs to construct the ML models. The lowest mean temperature (19.3 °C) was observed during 2016, which, at the same time, presented the lowest mean THI1-THI9 (58.1-72.0), highest mean RH (95.6%), and daily rainfall (3.9 mm). On the contrary, 2019 had the highest maximum temperature (44.9 °C) and, until March, the lowest mean RH (69.2%), and daily rainfall (0.3 mm), as well as the highest    Mean values per season of each year for temperature-humidity index (THI9) and the four parameters used as targets in the machine learning (ML) models to represent the effect of different weather patterns on potential heat stress, milk productivity, and quality. Table 1 shows the minimum, maximum, and mean values per year of each parameter used as inputs to construct the ML models. The lowest mean temperature (19.3 °C) was observed during 2016, which, at the same time, presented the lowest mean THI1-THI9 (58.1-72.0), highest mean RH (95.6%), and daily rainfall (3.9 mm). On the contrary, 2019 had the highest maximum temperature (44.9 °C) and, until March, the lowest mean RH (69.2%), and daily rainfall (0.3 mm), as well as the highest Figure 2. Mean values per season of each year for temperature-humidity index (THI 9 ) and the four parameters used as targets in the machine learning (ML) models to represent the effect of different weather patterns on potential heat stress, milk productivity, and quality. Table 1 shows the minimum, maximum, and mean values per year of each parameter used as inputs to construct the ML models. The lowest mean temperature (19.3 • C) was observed during 2016, which, at the same time, presented the lowest mean THI 1 -THI 9 (58.1-72.0), highest mean RH (95.6%), and daily rainfall (3.9 mm). On the contrary, 2019 had the highest maximum temperature (44.9 • C) and, until March, the lowest mean RH (69.2%), and daily rainfall (0.3 mm), as well as the highest mean THI 1 -THI 9 (68.6-82.8). Data for lactation days = 0 are the day the calf was born, and milk production commenced. Due to the voluntary milking system on the farm, there are some days when cows are not milked (i.e., milking frequency = 0). Furthermore, there were cows on the farm with extended lactations (>600 days). These were 'carryover' cows that were in an extended lactation because they failed to get pregnant in a timely manner.   Table 2 shows the minimum, maximum, and mean values of the parameters used as targets for the ML models. It can be observed that 2017 presented the highest milk yield per cow on average (30.7 kg day −1 ), although 2016 had the highest maximum milk yield per cow (65.4 kg day −1 ). Likewise, for milk protein, 2017 had the highest maximum value (6.1%), while 2018 presented the highest mean value (3.4%). Regarding milk fat content, 2019 had the highest maximum and mean values (10.9% and 4.3%, respectively). In 2019, the lowest average concentrate feed intake (4.0 kg day −1 ) was observed, while 2017 presented the highest mean (7.4 kg day −1 ) and the highest maximum value (24.3 kg day −1 ).  Table 3 shows the statistical results of both models to predict milk yield, milk fat, and protein content, and concentrate feed intake. It can be observed that both models presented similar results with high overall correlation coefficients (Model 1: R = 0.87; Model 2: 0.86; Figure 3). None of the models showed any signs of overfitting as the correlation coefficient of all stages was the same, and the performance of training (

Seasonality and Milk Yield
During the four years included in this study (2016-2019), there was a clear variation within seasons reflected by environmental parameters (THI) and milk productivity parameters (Figure 2). Higher heat stress risks for cows were observed in the summer of 2018-2019. Even though the THI parameter had a higher tendency, it was not significantly greater compared to the THI of summers belonging to 2017 and 2016 (THI = 79.7 compared to 78.7 and 77.5, respectively). However, milk yield and quality parameters were lower for 2018 compared with previous years. The high variability

Seasonality and Milk Yield
During the four years included in this study (2016-2019), there was a clear variation within seasons reflected by environmental parameters (THI) and milk productivity parameters (Figure 2). Higher heat stress risks for cows were observed in the summer of 2018-2019. Even though the THI parameter had a higher tendency, it was not significantly greater compared to the THI of summers belonging to 2017 and 2016 (THI = 79.7 compared to 78.7 and 77.5, respectively). However, milk yield and quality parameters were lower for 2018 compared with previous years. The high variability among all parameters shown through the years considered for this study can be considered as an advantage for ML modeling. These differences can be further supported by the data presented in Tables 1 and 2 with more specific data per year. Prolonged periods of high temperature and relative humidity have shown to be detrimental to dairy cows performance due to heat stress [19]. This makes more critical the development of cost-effective methodologies to measure and alleviate heat stress during these periods of high THI [20].

Machine Learning Models
By investigating thermotolerance in cows from a genetic point of view, it could help to decrease economic losses associated with lower milk productivity, quality, and animal welfare [21,22]. Other methods have been based on the physical modification of the environment, such as shade and shelters, and dietary interventions to reduce heat stress effects, such as grape residue [23], açai [24], betaine [14,25], slowly fermentable grains [26], and other types of feed [27,28].
The ML models developed in this research (Model 1 and Model 2) do not differ much when considering 36 genetically similar cows for heat tolerance compared to a total of 320 cows. There is a slight difference in the slope for the general model considering all cows (Model 2; slope = 0.74) compared to Model 1 (slope = 0.76). Considering highly heat stress-tolerant cows helps to decrease underestimations made by Model 1 compared to Model 2. However, it can be considered that these differences are minimal when considering the number of cows deemed for Model 1 (n = 36) compared to Model 2 (n = 312). Furthermore, Model 1 presented a slightly higher percentage of outliers, considering them as outside the 95% confidence bounds, with 3.88% compared to 3.60% for Model 2 (Figure 3), this difference is minimal and small for both models considering the number of observations in each model (Table 3).

Artificial Intelligence to Manage Heat Stress and Milk Productivity
Physical modification of the environment to reduce ambient temperature or increase heat loss from the animal body, such as shading and fans, have been previously applied for lactating buffaloes with positive results [29], and in dairy cows using mixed-flow fans [30]. However, one of the most effective methods found is spraying water over animals using sprinkler systems [31][32][33][34]. This paper proposed the implementation of Model 2 with an automated system based on an individual cow assessment combined with environmental factors obtained from an automatic meteorological station (AME) (Figure 4). The AME can be easily connected to a processing unit (microprocessor or smartphone App) that can read the RFID from cows that are going to be milked to obtain cow information required by the model (Figure 1). The model outputs can be automatically set to specific thresholds for volume and milk quality that is desired by the dairy farm. The system can then automatically control gates to direct individual cows either to a cooling system with water sprinklers, the cows to reduce heat stress or to normal milking sections. The heat-stressed cows will be assessed the next day again, if they continue to be heat stressed, they will go to the sprinkler system and get milked to avoid mastitis.
Sensors 2020, 20, x FOR PEER REVIEW 3 of 13 Figure 4. Proposed artificial intelligence (AI) application based on the automated processing of meteorological station and radio frequency identification system (RFID) for specific cow data input and machine learning (ML) processing. This system activates the gate system to draft cows to a cooling system or normal milking.
The technical advantages of the proposed system ( Figure 4) are: i) ML modeling is based on readily available environmental data by most of the dairy farms and from government services with meteorological stations close to the farms; ii) the environmental data can be automatically extracted from government services, such as the Bureau of Meteorology (BoM, Australia) [35] or by direct connectivity of a nearby automatic meteorological station to the RFID & ML Processing Unit ( Figure  4); iii) the digital database per cow can be implemented as part of the system to incorporate data such as programmed concentrate feed, lactation days and number, milking frequency, and liveweight. This information will need to be updated by the dairy farm personnel; iv) cows can be identified by the system with normal RFID systems to extract cow data automatically from databases, and v) the system requires an automated gate system to draft cows to the heat stress sprinkler system or the normal milking facilities.
The managerial advantages that could be obtained by implementing the system proposed are: i) milk volume and quality information available in real-time, per cow, and according to daily environmental conditions; ii) prediction of actual concentrate feed intake per cow for feed monitoring management compared to programmed concentrate feed; iii) real-time information to manage heat stress in a per cow basis to increase efficiency and maintain milk volumes and quality set as . Proposed artificial intelligence (AI) application based on the automated processing of meteorological station and radio frequency identification system (RFID) for specific cow data input and machine learning (ML) processing. This system activates the gate system to draft cows to a cooling system or normal milking.
The technical advantages of the proposed system ( Figure 4) are: (i) ML modeling is based on readily available environmental data by most of the dairy farms and from government services with meteorological stations close to the farms; (ii) the environmental data can be automatically extracted from government services, such as the Bureau of Meteorology (BoM, Australia) [35] or by direct connectivity of a nearby automatic meteorological station to the RFID & ML Processing Unit ( Figure 4); (iii) the digital database per cow can be implemented as part of the system to incorporate data such as programmed concentrate feed, lactation days and number, milking frequency, and liveweight. This information will need to be updated by the dairy farm personnel; (iv) cows can be identified by the system with normal RFID systems to extract cow data automatically from databases, and (v) the system requires an automated gate system to draft cows to the heat stress sprinkler system or the normal milking facilities. The managerial advantages that could be obtained by implementing the system proposed are: (i) milk volume and quality information available in real-time, per cow, and according to daily environmental conditions; (ii) prediction of actual concentrate feed intake per cow for feed monitoring management compared to programmed concentrate feed; (iii) real-time information to manage heat stress in a per cow basis to increase efficiency and maintain milk volumes and quality set as objectives, and (iv) data recorded from specific dairy farms can be incorporated in the model to increase the accuracy of target predictions.
With these considerations, an AI system for dairy farms can be implemented with reasonable investment affordable to small and medium dairy farmers. An alternative or complementary approach to an engineering solution may be to introduce dietary interventions such as betaine or antioxidants to cows likely to experience heat stress [14,28]. However, the time lag before the tissue concentrations of these nutrients are optimized could reduce the immediacy of this approach.
It should be noted that individual pasture intake could not be included in the model as the cows grazed as a single herd, so it was not measured. While this could no doubt add precision to the model, individual pasture intake cannot be measured under commercial grazing systems, and inclusion in the model would reduce its commercial utility.

Conclusions
The machine learning models developed in this research may be applied to assess automatically animal welfare, milk productivity, and quality. Based on the inputs of the models, this machine learning modeling technique can be applied to any dairy farm. Implementation of Artificial Intelligence in dairy farms and the ML models developed here will require minimal technological additions, automated gate, and cooling systems. This paper has shown a practical application of AI using detailed information from a robotic dairy farm for the benefit of small and medium dairy farms to increase competitiveness in an increasingly demanding international market.