Abstract
Subclinical mastitis in cows is a major challenge to the global development of the dairy sector, as it can reduce milk yield and lead to significant financial losses for dairy farmers. Given the difficulty in detecting subclinical mastitis and the growing availability of sensor data during milking, the application of machine learning techniques may offer a solution to more effectively and efficiently detect the problematic condition. Farmers and managers are more likely to use subclinical mastitis prediction tools if they can easily understand how the models work and why they make certain predictions. The advent of Explainable Boosting Machines (EBM) represents an optimal solution, offering results that are both transparent in the decision-making processes and interpretable to domain experts, while maintaining strong predictive power. The study compares models built with readily available data from milking machines to those using more expensive milk characteristic data to determine if there’s an “explanation deficit” when relying on the cheaper, more accessible data. The study finds that while models using the readily available features can perform well in prediction, the explanations derived from them are often less interpretable and harder to align with established veterinary knowledge compared to explanations from models using milk composition data. This suggests a trade-off between data accessibility and the clarity of the model’s reasoning for detecting the condition.
Similar content being viewed by others
1 Introduction
Detection of subclinical mastitis, a type of udder infection with no obvious clinical signs [2], is critical because it can result in loss of milk yield and risk of pathogen transmission [6, 9, 22, 24]. Similarly, clinical mastitis may result in these outcomes; however, milkers can identify clinical instances of mastitis by the abnormal milk [13]. In terms of the nature of subclinical mastitis, is characterised by a chronic, low-level infection that lack obvious signs, making it challenging to detect [21].
Given the difficulty in detecting subclinical mastitis and the growing availability of sensor data during milking, the application of machine learning techniques may offer a solution to more effectively and efficiently detect of the problematic condition. For subclinical mastitis prediction models to be adopted by farmers and farm managers these models need to be explainable [26]. This is important for farm managers and stakeholders to understand the contributing factors behind predictions, and thereby to develop trust and to support more informed decision-making. Research indicates that explainable models enhance transparency and comprehensibility, allowing users to validate the model’s outputs and confirm their alignment with domain knowledge and practical experience [4, 23]. In previous work [12], the objective was to identify the readily available features that could be used to build a subclinical mastitis prediction model that could achieve comparable performance to a model built using more expensive features. To this end, we continually added derived features from the readily available features to the model, with the aim of achieving better model performance. There is the potential, however, that this leads to uninterpretable models, which is a focus of this paper.
The interpretability of models, particularly those related to animal health, can be assessed in two principal ways: domain plausibility [16] and comprehensibility [18]. These are defined as:
-
1.
Domain plausibility is defined as the extent to which the interpretations derived from a model are consistent with the available domain knowledge. In the words of Warner et al. [31], domain knowledge is needed in order to extract the scientific outcome from the model or from individual elements of the model, and/or to explain such outcome. For example, based on domain knowledge, the contributions of specific model components can be better localised and investigated. Assessing the consistency with existing knowledge of the contributions of features to model outputs is the most straightforward way to measure domain plausibility. In the context of subclinical mastitis, if the model relies on traits that are known to be irrelevant or unrelated to mastitis, this could undermine confidence in the model.
-
2.
Comprehensibility refers to the extent to which humans can understand the explanations provided by a machine learning model, including understanding how the model works and the features the model uses [7]. It can be measured by assessing the simplicity of a model’s decision making and the understandability of features the model uses. Simplicity of decision making refers to how well the user can understand the workings of the model. One way in which this can be assessed is through the simplicity of the relationship between the values of an input feature and the output of the model. Monotonicity [29] is a desirable feature of the shape function illustrating the relationship between input feature values and a model output. A monotonic relationship occurs when an input value is increased and the output value either only increases or decreases. Such a clear and concise trend is more easily understood by farm managers and stakeholders. In addition, the understandability of the features is not negligible. According to Molnar [18], a complex transformation of features might be less comprehensible than the original features.
Jin et al. [12] has shown that high-performing models that predict sub-clinical mastitis can be built using only input features that are derived from the readily available features from modern milking parlour equipment (for example features based on milk flow rates, the duration of different phases of milking, etc [11]). This is in contrast to other models [1, 14, 19] that use input features based on milk characteristics that are expensive and time consuming to obtain. Using features derived from data from sensors in milking equipment, however, raises a question about the usefulness of the explanations that can be generated from a model that uses only these features compared to explanations that can be derived from models based on more information-rich features such as milk characteristics. Perhaps there is a price to pay—an explanation deficit—for using more readily available input features?
The objective of the study was to investigate this question. Models are trained using the Explainable Boosting Machine (EBM) algorithm [15, 20], a state of the art explainable machine learning method, and the explanations that can be generated from models trained using different feature sets is examined. The remainder of this study is structured as follows. Section 2 describes the data used for this study, and outlines the main analytical tool used for this study. The results of the experiment are presented in Sect. 3. Finally, Sect. 4 concludes the study.
2 Materials and Methods
2.1 Data collection
Data used as part of this paper were collected as part of wider milking management study at the Teagasc Research Centre at Moorepark, Ireland. This study was conducted with approval of the Teagasc Animal Ethics Committee (TAEC; TAEC2021-321), and in accordance with the Animal Health and Welfare Act 2013 (updated to 1 September 2023) [8] and the European Community Directive 86/609/EEC [5].
This farm operates a spring calving grass-based milk production system. The research centre milking parlour was a midi-line 30-unit DairyMaster herringbone, swing-over milking system (DairyMaster, Ireland). The cows on the farm were milked twice per day, and the milking system utilised simultaneous pulsation and was fitted with automatic cluster removers and weigh-all milk meters (DairyMaster, Ireland). The milk flow-rate switch point was set to 0.2 kg/min, i.e. when the milk flow from the cows reached 0.2 kg/min at the end of milking, the cluster was automatically removed by the milking machine.
The data utilised in this study was collected from March 2021 to October 2021, covering a period of eight months, with a total of 293 cows. The animals were predominately Holstein-Friesian (with small numbers of Jerseys and Norwegian Reds). Out of the 293 cows in the study, 92 were first-time calvers (primiparous) and 201 had calved more than once (multiparous). On average, the cows had been in milk for 149 days, with a range from 5 to 293 days. All collected data (including data following high SCC readings) were used for experiments, the total number of milking events for the dataset was 119,548.
Data available on farms can be broadly classified into two categories: those that are readily available and those that are more expensive, based on their sampling frequency and cost of acquisition. While data such as SCC and advanced milk composition analysis (e.g., fat, protein, and lactose content) offer valuable insights for detecting subclinical mastitis, they require the use of specialised equipment or laboratory facilities to perform the necessary measurements, which results in higher costs for implementation. In the present study, a composite sample of milk was obtained on a weekly basis from each cow via the milk meters and subsequently transferred to a laboratory for composition and SCC analysis via a Fossomatic machine (Foss, Denmark). Consequently, the dataset contains 15,250 milk composition and SCC recordings. Features extracted from such data are referred to as the expensive features.
Modern precision dairy farming technology is capable of measuring high frequency data, enabling the collection of detailed features describing a range of aspects of the farm. The most common features, including total milk yield, peak milk flow-rate, milking time, and electrical conductivity, are routinely recorded by almost all milking systems and provide a basic set of data for monitoring cow productivity and health. These are examples of what we refer to as the readily available features. In addition, another readily available data source, milk flow profiles, has been introduced to record the cumulative milk yield during each milking session for individual cows. These profiles capture fine-grained variations in milk production over time, offering more detail than traditional milk flow traits—such as total milk yield, milk flow-rate, and milking time—used in other studies [27, 32]. Briefly, milk flow profiles show the amount of milk collected every ten seconds during the milking process. Figure 1 shows plots of the morning (AM) and evening (PM) milk flow profiles for four cows on the same day. Note that the curves show the cumulative milk yield starting at zero and continuing to the full yield amount when milking is complete.
Examples of milk flow profiles from four cows for morning (AM) and evening (PM) milkings on the same day
2.1.1 Input variables
In this study, the data was collected from various sources, including detailed milk flow profiles for each milking event (usually twice per day), daily milking machine records, and weekly laboratory testing of milk characteristics (including fat, protein and SCC). It is important to note that once cows are subjected to a clinical diagnosis and subsequent treatment, they are excluded from the collection of data from milking machines. The different data sources used are described in more detail as follows:
-
1.
A total of 81 features were extracted from the milk flow profiles,Footnote 1 and these derived features were grouped into three categories. Firstly, there are statistical time domain features, which include maximum and minimum values, kurtosis, the standard deviation, average over first differences, and the number of different peaks. Secondly, there are univariate temporal features that capture the dynamics of the milk flow profile. Examples of these features include auto-correlation, entropy, and total energy. Thirdly, there are spectral time-frequency features that represent changes in the frequency domain over time.
-
2.
Milking machine data includes sensor measurements of milking features such as maximum milk flow rates, milk flow rate at cluster removal, the deviation in milk yield between milkings, and electrical conductivity, as detailed in Table 1. The data gathering equipment was fitted to the milking system and data were collected as the cows were milked, without any manual intervention required.
-
3.
Milk characteristic data, includes information on milk composition and SCC. Milk characteristics were measured approximately every 7 days, from samples collected during AM milking. Samples collected during the milking were transported to a laboratory for analysis and eight characteristics (including SCC) were measured. Details of these are shown in Table 2.
2.1.2 Outcome definition
The presence of subclinical mastitis in cows is detected by the measurement of SCC levels, with thresholds defined as the cut-off values that differentiate between healthy and infected cows. Cows were identified as having subclinical mastitis once SCC measurements exceeded the threshold; cows with SCC measurements below the threshold were considered healthy. The identification of subclinical mastitis in dairy cattle requires the distinction between primiparous and multiparous cows. Primiparous cows, having only experienced one calving, are characterised by underdeveloped mammary glands and an immune system less mature, which results in an increased risk of mastitis. Therefore, threshold of 150,000 cells/ml was used to enable timely detection and treatment of subclinical mastitis of these cows. In contrast, multiparous cows have enhanced mammary development and a more robust immune response, making a higher SCC threshold of 250,000 cells/ml a better fit for the identification of subclinical mastitis [10].
2.2 Experiment design
The main analytical tool used in this study is the EBM [20], which is widely recognised for its strong performance in prediction tasks and its inherent explainability. The EBM is a glass-box model that combines the strengths of decision trees and Generalized Additive Models (GAMs) to provide both high predictive performance and explainability. Unlike black-box models, EBMs provide insights into how and why predictions are made, making them particularly valuable in domains where understanding the decision-making process is as important as the decision itself. EBM offers two perspectives on feature contribution: the global explanation and the local explanation.
The global explanation provides an overall picture of how each feature influences the model’s predictions across all instances. It ranks features by their importance, offering insights into the general patterns and relationships within the data. This perspective is invaluable for understanding which features are most important. In addition, the EBM also provides a visualisation of the contribution of the value of an individual feature to the predicted outcome from an EBM model, which can show the relationship between changes in feature values and changes in the predicted outcome. The visualisation of this relationship is referred to as a shape function. As an illustration, the top part of Fig. 2 displays the estimated shape function for the feature “milk yield”. The bottom histograms illustrate the distribution of milk yield for subclinical mastitis cases (represented in red) and healthy cases (represented in blue), respectively. Because each feature is visualised individually, on the one hand we can directly see and understand how each feature affects the predicted outcome, and on the other hand this helps us to assess whether these effects are domain plausible.
An example of “yield” contribution
On the other hand, local explanations offers a detailed explanation of how the features contribute to the prediction for an individual instance. Figure 3 shows an example of a local explanation generated from an EBM to indicate the features in query instance that contribute to the predicted outcome. The vertical axis labels show the contributing features along with their values for the query instance. The bars represent the magnitude of the feature’s contribution to the predicted outcome, with blue representing a negative effect, corresponding to the health cases and red representing a positive effect, indicating to subclinical mastitis cases. For example, the “milk lactose” feature, with a value of 4.17 for this query instance, gave the greatest contribution (3.68) to the prediction of subclinical mastitis for this instance. This insight is particularly useful for targeting treatments to specific animals or situations, based on the unique combination of factors that influence their risk of subclinical mastitis.
An example of local explanation
In this experiment we built models to detect subclinical mastitis using the two categories of features: expensive features, and readily available features. Two separate EBMs are developed corresponding to the feature categorization:
-
Expensive features model, which uses only expensive features for predicting subclinical mastitis.
-
Readily available features model, which predicts subclinical mastitis using only readily available features.
The core of the experimental design focuses on the analysing the usefulness of both global and local explanations provided by EBMs trained using the different feature sets. We analyze the usefulness of explanations based on domain plausibility and comprehensibility. To assess domain plausibility to feature importance and shape functions included in global explanations are compared to known relationships discussed in the literature. To assess the comprehensibility of explanations.
3 Results
This section presents the results of the experimental design to assess the quality of the explanations generated using the two EBMs built, one using the expensive features and one use the readily available features. First the performance of the two models is assessed to demonstrate that the EBM models perform at a level similar to the models described in Jin et al. [12]. Then, we assess the global explanations followed by the local explanations.
3.1 Model performance
Table 3 shows the performance of the two models built (the expensive features model, and the readily available features model). The AUC of the readily available features model is 0.780, while that of the expensive features model was 0.730.
The performance of the EBMs built to predict subclinical mastitis was similar to that of the GBM models presented in Jin et al. [12]. This shows that the EBM model performs equally well in predicting subclinical mastitis as the best GBM model.
3.2 Global explanations: the expensive features model
This section focuses on the expensive features model, assessing the global explanations generated from it in terms of domain plausibility and comprehensibility. Figure 4 illustrates the feature importance for the expensive features model. Red bars indicate the expensive features (features related to milk characteristics) and yellow bars indicate features based on basic cow information (parity and DIM). This chart is part of the global explanation generated from the EBM. The features used in the expensive feature model are the components of milk tested in the laboratory, which have not been transformed so that the meaning of each feature is clear at a glance.
The global explanation describes the relationship between features and subclinical mastitis cases for the entire dataset. The top 5 features most related to the prediction of subclinical mastitis in the expensive feature model are lactose, parity, fat, FFA and DIM, with lactose and parity being much more important than the other features. Next, we look in detail at the global explanation extracted from the EBM based on each of these features and assess them in terms of domain plausibility and comprehensibility.
The global explanation of feature importance for the expensive features model. The feature names are explained in Table 2
In accordance with the global explanation of the expensive features model in Fig. 4, the feature “lactose” is the most important when predicting subclinical mastitis. Figure 5 shows the contribution plot generated from the expensive features model for the milk lactose feature. Figure 5 shows a clear monotonic relationship between milk lactose values and model output. As stated before, monotonicity provides a straightforward understanding of the relationship between a feature and a model output. In this case, the relationship between milk lactose and the likelihood of subclinical mastitis is evident: as milk lactose increases, the risk of subclinical mastitis notably decreases.
The feature contribution of “Lactose” for the expensive features model
Furthermore, this explanation is consistent with the existing knowledge of experts within this field. As demonstrated by Ruegg [25], the concentration of milk lactose is a significant predictor of cows with subclinical mastitis. The process of lactose synthesis takes place in the mammary gland tissue and its concentration decreases as the synthesis capacity of the affected mammary gland tissue is reduced. Overall, these observations highlight the comprehensibility and domain plausibility of the explanation for the role of the milk lactose feature in predicting subclinical mastitis.
The feature importance plot from the global explanation in Fig. 4 shows that the feature “parity” is the next most important feature in the model. Figure 6 plots the relationship between parity and subclinical mastitis. Figure 6 illustrates a distinct trend in the relationship between the incidence of subclinical mastitis in cows and the cumulative number of calvings. It is evident that, with the exception of cows calving for the first time, the relationship is positive, exhibiting a notable increase in mastitis risk with the number of calvings, particularly in cases where more than five calvings have occurred. It can be reasonably inferred that this observed trend is probably related to changes in the position of the cow’s udder and historical udder infections in cows. First-calf cows have not yet adapted to the milking process, which increases the risk of damage to the udder. Multiparous cows, those that have calved five or more times, are known to have a higher incidence of udder health issues [30], which is consistent with our findings. The idea is that udder prolapse has the potential to injure the teat and udder structure, making it easier for bacteria to enter. In short, the trend between parity and the prediction of subclinical mastitis also has a monotonicity that is easy to understand. Furthermore, the information provided by the feature contributions is also consistent with expert explanations that are domain plausible.
The feature contribution of “Parity” for the expensive features model
Following parity, the next most important feature in the global explanations in the feature importance plot is the feature “fat”. Several studies have provided evidence that mastitis has the effect of changing milk fat levels. As shown in Fig. 7, the overall trend between milk fat and the prediction of subclinical mastitis is monotonic, and cows with milk fat levels greater than 5.07 have an increased risk of subclinical mastitis. This trend is consistent with the understanding that changes in milk composition may signal an underlying mammary infection. Cows suffering from subclinical mastitis can often have changes in milk composition due to the inflammatory process, which can affect the normal synthesis of milk constituents such as fat [17]. Thus, the use of milk fat as a significant feature in the model is both comprehensible and supported by expert knowledge. However, observing the more specific trends, when the milk fat content was below 5.07, the relationship with the predicted value was nonlinear and exhibited a U-shaped pattern. As the milk fat content increases from 4.12 to 4.75, the negative effect of milk fat on predicted values first decreases and then increases. This may not provide a very clear explanation, but it does not reduce the overall comprehensibility and domain plausibility of the model.
The feature contribution of “Fat” for the expensive features model
Similarly, Fig. 4 shows that the feature “FFA” are one of the most important feature in predicting subclinical mastitis. Figure 8 examines the relationship between milk FFA concentration and the likelihood of subclinical mastitis. This relationship suggests that FFA is known to play a role in the presence of subclinical mastitis. The concentrations of these substances can be used as indicative markers of lipid mobilisation and metabolism in a number of different physiological contexts. An elevation in free fatty acids has been observed to correlate with inflammatory responses and metabolic perturbations in mammary gland tissues. During the onset and progression of mastitis, the mammary gland undergoes a series of immune-related processes aimed at combating invading pathogens. This immune response can result in the release of inflammatory mediators that lead to elevating the levels of free fatty acids. However, despite the clear influence of the FFA feature on the outcome (as shown in Fig. 8), the observed trend conflicts with domain expert findings.
The feature contribution of “FFA” for the expensive features model
Next, the feature importance plot from the global explanation shows that the feature “DIM” is another critical feature in the model. Figure 9 shows the relationship between DIM and the incidence of subclinical mastitis at different stages of lactation. There is a correlation between DIM and the incidence of subclinical mastitis in dairy cows, with the incidence of mastitis being significantly higher in early lactation compared to late lactation. Figure 9 shows that days in milk had a significant positive effect on subclinical mastitis in the pre-mid lactation period. In addition, there was a significant negative shift in this effect as the time moved into the later stages of lactation. This pattern is consistent with existing literature, such as Ruegg [25], which highlights that the effect of DIM on the development of subclinical mastitis is considered important. Typically, cows in early lactation or high parity have an increased risk of developing subclinical mastitis. This negative trend in the later stages of lactation observed in the model predictions supports this biological understanding and demonstrates the consistency of the model with established domain knowledge. Overall, the contribution of the feature days in milk is easy to comprehend as well, and is consistent with the findings of related mastitis studies, demonstrating its domain plausibility.
The feature contribution of “DIM” for the expensive features model
In summary, Table 4 shows a summary of the assessment of the interpretability of the most important features in the expensive features model. Except for FFA the patterns extracted from the EBM model all match what has already been published the literature, giving them all a high degree of domain plausability. In terms of comprehensibibility these features have a natural advantage as they are inherently understandable since they directly measure characteristics commonly used and discussed on farms. Moreover, most of the features display simple monotonic relationships with the mastitis detection target making their impact on model outcomes easy to understand.
3.3 Global explanations: the readily available features model
This section focuses on the readily available features model, assessing the effectiveness of its explanations in terms of domain plausibility and comprehensibility.
Figure 10 shows an overview of feature importance for the readily available features model generated as part of the global explanation. Green bars correspond to the readily available features and yellow bars correspond to features based on basic information about cows. The features used in the readily available features model are not only collected directly from the milking machine, but also extracted from the milk flow profiles through a number of transformations. The most important feature in the model is the feature “Parity”. The remaining important features are derived from milk flow profiles. Although we can explain the process to generate each feature individually, it is difficult to relate such transformation processes to domain characteristics because they often involve complex, abstract operations that do not directly correspond to the well-understood biological factors in the domain. In short, these processes are difficult to understand because they lack clear, intuitive links to established knowledge and practices within the domain.
The relationship between parity and subclinical mastitis in the readily available features model shown in Fig. 11 closely mirrors the trend seen in the expensive features model (shown in Fig. 6). This similarity provides further evidence that EBMs are domain plausible, as similar trends are obtained when the same features in different models.
The feature contribution of “Parity” for the readily available features model
The meaning of the feature “Flow Repeated Max Diff” is to check if the maximum value of milk yield is observed more than once, followed by calculating the difference between this result and the average value for the whole herd. Figure 12 shows that as the value of the feature increases, its effect on the predicted value varies between positive and negative effects many times. The value of the feature between the intervals − 0.88 to − 0.66 and − 0.28 to 0.43 shows a positive effect on the predicted value, while in other intervals a negative effect on the predicted value is shown.
The feature contribution of “Flow Repeated Max Diff” for the readily available features model
The fluctuating effects of the feature are challenging to interpret in a meaningful manner within the context of known factors related to subclinical mastitis. In contrast to other features that are consistent with veterinary knowledge, the observed trend does not have a clear or logical connection to established domain understanding. Consequently, although the feature’s impact can be described using the contribution plot, the absence of plausible links to domain knowledge leads to questioning of the comprehensibility. It can therefore be concluded that this explanation does not meet the criteria for being considered either comprehensible or domain plausible.
The feature “FlowRateAtStop 3DaysPrior Diff” is the difference between the milk flow rate at cluster removal 3 days before the SCC measurement date compared to the herd average. As shown in Fig. 13, this feature seems to point out that the focus should be on the stop milk flow rate 3 days ahead of the SCC measurement date, however, it is easy to observe that the majority of the values of this feature are located in the range of − 0.14 to 0.07. In other words, the majority of this feature shows a negative effect on the predicted values. In terms of comprehensibility, this explanation is relatively straightforward to follow. It logically suggests that deviations in the milk flow rate at specific points in time, relative to the herd average, could influence the prediction of subclinical mastitis. The observed negative trend is also consistent with domain knowledge, as a lower-than-average flow rate could be indicative of underlying health issues, such as early signs of mastitis, that might reduce milk production. Therefore, the explanation provided by this feature is both comprehensible and consistent with domain knowledge, thereby reinforcing the confidence in the model’s ability to predict subclinical mastitis.
The feature contribution of “FlowRateAtStop 3DaysPrior Diff” for the readily available features model
The purpose of the feature “OrderChange 1DayPrior Diff” is the difference between the milking order and the last AM milking order of the cow, followed by calculating the difference between this result and the average value for the whole herd. It can be seen in Fig. 14 that the contribution of this feature is non-linear, and as the value of this feature grows, its impact on the results varies many times between positive and negative effects, and it is difficult to comprehend this trend.
The feature contribution of “OrderChange 1DayPrior Diff” for the readily available features model
Conductivity is a highly interpretable feature among the readily available data, as its relationship with subclinical mastitis is well-understood and straightforward. The clear trend displayed in Fig. 15, where the probability of having subclinical mastitis increases with higher conductivity, makes this feature comprehensible to both domain experts and practitioners. This trend is also domain-plausible, aligning with established knowledge that increased conductivity in milk is often associated with infections that alter milk composition Tian et al. [28]. Therefore, the explanation provided by this feature is both easy to understand and consistent with expert understanding of mastitis indicators.
The feature contribution of “Conductivity” for the readily available features model
The feature “Deviation diff” represents the difference between the value of deviation and the herd average for that feature. As illustrated in Fig. 16, the impact of the “Deviation Diff” feature tends to be monotonic. Specifically, as the value of the feature increases, the effect on the decision to predict subclinical mastitis changes from positive to negative. This pattern is straightforward and readily comprehensible, providing a clear explanation. Furthermore, the observed trend is consistent with the existing understanding within the domain context. Consequently, the explanation provided by this feature is both comprehensible and domain-plausible
The feature contribution of “Deviation Diff” for the readily available features model
Table 5 summarises the assessment of the usefulness of the feature explanations for the readily available features model. Because the features used in the readily available features model are mostly derived features calculated from the milk flow profile data or milking machine data they have an inherent disadvantage in terms of domain plausibility. these features are so specific that there are not studies in the literature examining them and they are too far removed from the raw data from which they are calculated to infer their plausibility based on the plausibility of those features. Only the relationship with the mastitis target feature for features based on simple measurements of characteristics already usually used and discussed on farms (parity, milk flow at stop (3 days prior), and milk conductivity can be validated in the literature.
This disadvantage of derived features also extends to their understandability. Most of the most important features in the readily available features model are not characteristics usually used and discussed on farms and farmers and farm managers will not have an intuitive understanding of them. Lastly, the relationships between the most important features in the readily available features model and the mastitis detection target are not simple (for example they display non-monotonic relationships) making them less useful than the explanations generated form the expensive features model.
Together these observations illustrate the explanation deficit that rises from using features extracted from readily avialble data sources. Although the models that can be trained using them are as effective as the models trained using more expensive features, the explanations that we can generate from this models are not as effective. This is the price that must be paid.
3.4 Local explanations
For an EBM model a local explanation is an explanation of the model prediction for a specific input, in this case the milking data collected from a single cow. Thus, the local explanation describes which features are the main contributors to the model’s output of subclinical mastitis likelihood. In this section the local explanations generated from the expensive features model and the readily available features model for a number of input instances are compared to assess their interpretability.
Figure 17 shows examples of local explanations generated for predictions made using the expensive features model. It is clear how the model arrived at the decision that this was a case of subclinical mastitis. In particular, lower than normal lactose content, higher than normal fat content and first calving cow were the main contributors to the model predicted this instance to be a case of subclinical mastitis. Similarly, for the second instance, we can easily interpret the prediction of a healthy case-based on higher-than-normal lactose content, second parity, and late lactation.
Local explanations generated from the expensive features model for two input instances
In Fig. 18, two examples of local explanations of predictions made using the readily available features models are provided. The main contributors to the model’s decisions are derived from features that have multiple transformations applied to them, which can result in their meanings becoming less intuitive and more difficult to comprehend. The information provided by local explanations of predictions made using the readily available features model is significantly weaker in domain plausibility and comprehensibility compared to local interpretations from the expensive features model. There are few interpretations that are directly accessible.
4 Conclusions
This study began by examining the key features identified in the global explanations of Explainable Boosting Machines (EBMs). We first evaluated the individual contributions of top-ranked features, focusing on their domain plausibility and comprehensibility. For the model built using the readily available features, it was often difficult to find expert knowledge to support the observed trends. This reflects a key challenge-what we refer to as an explanation deficit-where some derived features, despite contributing to predictions, lack clear links to established domain knowledge.
In contrast, the global explanations for the expensive features model were more aligned with veterinary expertise, with trends that were both intuitive and scientifically supported. However, local explanations from the readily available features model revealed that these features still play a significant role in prediction, even if their relationships with subclinical mastitis are less interpretable.
Overall, we conclude that the readily available features are not inherently inferior to expensive features for predicting subclinical mastitis. Their main advantages lie in their frequent availability and strong predictive performance. Yet, the lack of interpretability-particularly for lower-ranked derived features-presents a limitation for real-world adoption. To bridge this gap, further domain-driven validation is recommended.
In practical terms, the readily available features offer a cost-effective and scalable solution for early detection of subclinical mastitis. With enhanced interpretability and continued integration of domain knowledge, these models could become valuable decision-support tools on dairy farms.
Data availability
Data sets generated during the current study are available from the corresponding author on reasonable request. The milking data used in this study is collected in collaboration between Teagasc and an industry partner under licence and so they are not publicly available as restrictions apply.
Notes
All features were extracted from milk flow profiles using the tsfresh package in Python [3].
References
Anglart D, Emanuelson U, Rönnegård L, et al. Detecting and predicting changes in milk homogeneity using data from automatic milking systems. J Dairy Sci. 2021;104(10):11009–17.
Argaw A. Review on epidemiology of clinical and subclinical mastitis on dairy cows. Food Sci Qual Manag. 2016;52(6):56–65.
Christ M, Braun N, Neuffer J, et al. Time series feature extraction on basis of scalable hypothesis tests (tsfresh-a python package). Neurocomputing. 2018;307:72–7.
Doshi-Velez F, Kim B. Towards a rigorous science of interpretable machine learning. arXiv preprint; 2017. arXiv:1702.08608.
European Community. Council Directive 86/609/EEC of 24 November 1986 on the approximation of laws, regulations and administrative provisions of the Member States regarding the protection of animals used for experimental and other scientific purposes. Official Journal L 1986;358, 1–28. http://data.europa.eu/eli/dir/1986/609/oj. Accessed 29 Aug 2023.
Geary U, Lopez-Villalobos N, Begley N, et al. Estimating the effect of mastitis on the profitability of Irish dairy farms. J Dairy Sci. 2012;95(7):3662–73.
Gleicher M. A framework for considering comprehensibility in modeling. Big Data. 2016;4(2):75–88.
Government of Ireland. Animal health and welfare act 2013. Updated in 2023; 2013.
Halasa T, Huijps K, Østerås O, et al. Economic effects of bovine mastitis and mastitis management: a review. Vet Q. 2007;29(1):18–31.
Jensen DB, van der Voort M, Hogeveen H. Dynamic forecasting of individual cow milk yield in automatic milking systems. J Dairy Sci. 2018;101(11):10428–39.
Jin C, Upton J, Mac Namee B. Do cows have fingerprints? using time series techniques and milk flow profiles to characterise cow milking performance and detect health issues. In: International workshop on advanced analytics and learning on temporal data. Springer; 2023. p. 230–42.
Jin C, Upton J, Bazargani MHZ, et al. Using milk flow profiles for subclinical mastitis detection. Smart Agric Technol. 2024;9: 100537.
Khan M, Khan A. Basic facts of mastitis in dairy animals: a review. Pak Vet J. 2006;26(4):204.
Khatun M, Thomson P, Kerrisk K, et al. Development of a new clinical mastitis detection method for automatic milking systems. J Dairy Sci. 2018;101(10):9385–95.
Lou Y, Caruana R, Gehrke J, et al. Accurate intelligible models with pairwise interactions. In: Proceedings of the 19th ACM SIGKDD international conference on Knowledge discovery and data mining; 2013. p. 623–31.
Lu X, Ma J. Does faithfulness conflict with plausibility? an empirical study in explainable ai across NLP tasks; 2024. arXiv preprint arXiv:2404.00140.
Martins L, Barcelos MM, Cue RI, et al. Chronic subclinical mastitis reduces milk and components yield at the cow level. J Dairy Res. 2020;87(3):298–305.
Molnar C. Interpretable machine learning, 2nd edn; 2022. https://christophm.github.io/interpretable-ml-book.
Naqvi SA, King MT, Matson RD, et al. Mastitis detection with recurrent neural networks in farms using automated milking systems. Comput Electron Agric. 2022;192: 106618.
Nori H, Jenkins S, Koch P, et al. Interpretml: a unified framework for machine learning interpretability; 2019. arXiv preprint arXiv:1909.09223.
Ogola H, Shitandi A, Nanua J. Effect of mastitis on raw milk compositional quality. J Vet Sci. 2007;8(3):237–42.
Regan Á, Clifford S, Burrell AM, et al. Exploring the relationship between mastitis risk perceptions and farmers? Readiness to engage in milk recording. Prev Vet Med. 2021;193: 105393.
Ribeiro MT, Singh S, Guestrin C. “ why should i trust you?” explaining the predictions of any classifier. In: Proceedings of the 22nd ACM SIGKDD international conference on knowledge discovery and data mining; 2016. p. 1135–1144
Romero J, Benavides E, Meza C. Assessing financial impacts of subclinical mastitis on Colombian dairy farms. Front Vet Sci. 2018;5:273.
Ruegg PL. A 100-year review: mastitis detection, management, and prevention. J Dairy Sci. 2017;100(12):10381–97.
Ryan C, Guéret C, Berry D, et al. Predicting illness for a sustainable dairy agriculture: predicting and explaining the onset of mastitis in dairy cows; 2021. arXiv preprint arXiv:2101.02188.
Tamburini A, Bava L, Piccinini R, et al. Milk emission and udder health status in primiparous dairy cows during lactation. J Dairy Res. 2010;77(1):13–9.
Tian F, Wang Z, Yu S, et al. Clinical mastitis detection by on-line measurements of milk yield, electrical conductivity and deep learn. In: Journal of physics: conference series. IOP Publishing, 2020;012046.
Van der Velden BH, Kuijf HJ, Gilhuijs KG, et al. Explainable artificial intelligence (xai) in deep learning-based medical image analysis. Med Image Anal. 2022;79: 102470.
Waller KP, Lundberg Å, Nyman AK. Udder health of early-lactation primiparous dairy cows based on somatic cell count categories. J Dairy Sci. 2020;103(10):9430–45.
Warner D, Vasseur E, Lefebvre DM, et al. A machine learning based decision aid for lameness in dairy herds using farm-based records. Comput Electron Agric. 2020;169: 105193.
Zucali M, Bava L, Sandrucci A, et al. Milk flow pattern, somatic cell count and teat apex score in primiparous dairy cows at the beginning of lactation. Ital J Anim Sci. 2009;8(1):103–11.
Funding
This publication is the result of research conducted with the financial support of Science Foundation Ireland (SFI) and the Department of Agriculture, Food and Marine, acting on behalf of the Government of Ireland, under Grant Number [16/RC/3835]. In addition, DairyMaster provided further financial and technical assistance.
Author information
Authors and Affiliations
Contributions
Changhong Jin: conceptualization, methodology, software, data curation, visualization, writing—original draft; John Upton: resources, data curation, writing—review and editing; project administration; supervision, funding acquisition; Brian Mac Namee: methodology, writing—review and editing, supervision, funding acquisition.
Corresponding author
Ethics declarations
Ethics approval and consent to participate
Data used as part of this modelling paper were collected as part of a wider milking management study at the Teagasc Research Centre at Moorepark, Ireland. This study was conducted with approval of the Teagasc Animal Ethics Committee (TAEC; TAEC2021-321), and in accordance with the Animal Health and Welfare Act 2013 (updated to 1 September 2023) and the European Community Directive 86/609/EEC.
Consent for publication
The data and figures in the manuscript have been agreed upon by all authors, and the final manuscript has been submitted to the Journal of Discover Agriculture.
Competing interests
The authors declare no competing interests.
Additional information
Publisher's Note
Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
Appendix: Model Parameter Configuration
Appendix: Model Parameter Configuration
Table shows the detailed description of Table 6 summarizes the definitions and interpretations of the top important features in the readily available features model.
Rights and permissions
Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article's Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article's Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http://creativecommons.org/licenses/by/4.0/.
About this article
Cite this article
Jin, C., Upton, J. & Mac Namee, B. Exploring explanation deficits in subclinical mastitis detection with explainable boosting machines. Discov Agric 3, 87 (2025). https://doi.org/10.1007/s44279-025-00246-z
Received:
Accepted:
Published:
Version of record:
DOI: https://doi.org/10.1007/s44279-025-00246-z



















