| Literature DB >> 32664417 |
Christian Post1, Christian Rietz2, Wolfgang Büscher3, Ute Müller1.
Abstract
The aim of this study was to develop classification models for mastitis and lameness treatments in Holstein dairy cows as the target variables based on continuous data from herd management software with modern machine learning methods. Data was collected over a period of 40 months from a total of 167 different cows with daily individual sensor information containing milking parameters, pedometer activity, feed and water intake, and body weight (in the form of differently aggregated data) as well as the entered treatment data. To identify the most important predictors for mastitis and lameness treatments, respectively, Random Forest feature importance, Pearson's correlation and sequential forward feature selection were applied. With the selected predictors, various machine learning models such as Logistic Regression (LR), Support Vector Machine (SVM), K-nearest neighbors (KNN), Gaussian Naïve Bayes (GNB), Extra Trees Classifier (ET) and different ensemble methods such as Random Forest (RF) were trained. Their performance was compared using the receiver operator characteristic (ROC) area-under-curve (AUC), as well as sensitivity, block sensitivity and specificity. In addition, sampling methods were compared: Over- and undersampling as compensation for the expected unbalanced training data had a high impact on the ratio of sensitivity and specificity in the classification of the test data, but with regard to AUC, random oversampling and SMOTE (Synthetic Minority Over-sampling) even showed significantly lower values than with non-sampled data. The best model, ET, obtained a mean AUC of 0.79 for mastitis and 0.71 for lameness, respectively, based on testing data from practical conditions and is recommended by us for this type of data, but GNB, LR and RF were only marginally worse, and random oversampling and SMOTE even showed significantly lower values than without sampling. We recommend the use of these models as a benchmark for similar self-learning classification tasks. The classification models presented here retain their interpretability with the ability to present feature importances to the farmer in contrast to the "black box" models of Deep Learning methods.Entities:
Keywords: classification; lameness; machine learning; mastitis; sensor data
Mesh:
Year: 2020 PMID: 32664417 PMCID: PMC7411665 DOI: 10.3390/s20143863
Source DB: PubMed Journal: Sensors (Basel) ISSN: 1424-8220 Impact factor: 3.576
Per variable description of additional aggregation of sensor data, daily (feed and water intake data, and pedometer activity) and over multiple consecutive days (all variables except parity, days in milk and weeks in milk).
| Aggregation | Description |
|---|---|
| Daily | |
| Mean | Arithmetic mean |
| SD | Standard deviation |
| Median | Median |
| Sum | Sum of values |
| Max | Highest single value |
| Min | Lowest single value |
| Range | Max-Min |
| 3 highest (Sum) | Sum of the 3 highest values |
| 6 highest (Sum) | Sum of the 6 highest values |
| 3 lowest (Sum) | Sum of the 3 lowest values |
| 6 lowest (Sum) | Sum of the 6 lowest values |
| Sum Day | Sum of values from 04:01 to 20:00 |
| Sum Night | Sum of values from 20:01 to 04:00 |
| Day/Night ratio | Sum Day/Sum Night |
| Multiple days | |
| d-1 | Value of previous day |
| d-2 | Value 2 days before |
| d-3 | Value 3 days before |
| RM | Rolling Mean of previous 7 days |
| RMdiff | Difference of current day’s value to RM |
| RMprev | Rolling mean of previous week (d-8 to d-14) |
| slope | Slope of a linear regression from the recent 7 values |
Number of features by category, before feature selection.
| Category | Number of Features |
|---|---|
| Animal dependent variables | |
| Feed and water intake and visits | 189 |
| Activity | 127 |
| Milking | 77 |
| Concentrate intake | 25 |
| Body weight | 8 |
| Other 1 | 3 |
| Animal independent variables | |
| Climate | 4 |
1 parity, days and weeks in milk.
The 20 most important variables ranked by RF-I (mean ± 95% CI) with respective r-values (mean ± CI, all correlations with p < 0.001).
| Mastitis Treatments Classification | Lameness Treatments Classification | |||||
|---|---|---|---|---|---|---|
| Rank | Feature | RF-I 1 | r | Feature | RF-I | r |
| 1 | Last Milk recording SCC 2 | 0.039 ± 0.009 | +0.176 ± 0.016 | Feeding time with intake | 0.013 ± 0.005 | −0.105 ± 0.014 |
| 2 | Concentrate intake, slope | 0.014 ± 0.005 | −0.076 ± 0.016 | Feed intake Sum day, RMprev 3 | 0.012 ± 0.006 | +0.079 ± 0.010 |
| 3 | Milk conductivity p.m., slope | 0.013 ± 0.006 | +0.082 ± 0.024 | Activity, SD, RMprev | 0.012 ± 0.006 | −0.072 ± 0.012 |
| 4 | Feed intake (Median), RMprev | 0.011 ± 0.004 | +0.067 ± 0.010 | Feeding visits with intake | 0.011 ± 0.005 | −0.080 ± 0.013 |
| 5 | Feed intake (S.D.), RMprev | 0.011 ± 0.004 | +0.064 ± 0.008 | Activity (Range), RMprev | 0.010 ± 0.006 | −0.067 ± 0.011 |
| 6 | Feeding visit duration (mean), RM 4 | 0.011 ± 0.004 | +0.009 ± 0.006 | Activity (Max), RMprev | 0.010 ± 0.004 | −0.066 ± 0.011 |
| 7 | Feed intake 6 highest (Sum), RMprev | 0.011 ± 0.006 | +0.068 ± 0.009 | Air temperature | 0.010 ± 0.004 | −0.061 ± 0.015 |
| 8 | Feed intake 3 highest (Sum), RMprev | 0.010 ± 0.005 | +0.068 ± 0.009 | THI 5 | 0.009 ± 0.003 | −0.061 ± 0.015 |
| 9 | Feeding visit duration (mean), d−3 | 0.010 ± 0.004 | −0.002 ± 0.006 | Feed intake (SD), RM | 0.009 ± 0.004 | +0.098 ± 0.011 |
| 10 | Conc. intake abs. deviation, RM | 0.010 ± 0.004 | −0.047 ± 0.014 | Feeding time with intake, RM | 0.009 ± 0.006 | −0.062 ± 0.008 |
| 11 | Milk conductivity p.m., RMdiff 6 | 0.010 ± 0.005 | +0.080 ± 0.017 | Feeding time with intake, RMdiff | 0.009 ± 0.003 | −0.095 ± 0.018 |
| 12 | Feed intake (Max), RMprev | 0.009 ± 0.006 | +0.065 ± 0.01 | Drinking time with intake | 0.009 ± 0.005 | −0.065 ± 0.009 |
| 13 | Feed intake (Mean), RMprev | 0.009 ± 0.005 | +0.067 ± 0.01 | Feeding time with intake, slope | 0.008 ± 0.003 | −0.090 ± 0.019 |
| 14 | Feeding visits with intake, RMprev | 0.009 ± 0.006 | −0.060 ± 0.005 | Feed intake (Median) | 0.007 ± 0.001 | +0.107 ± 0.010 |
| 15 | Feed intake (S.D.), RM | 0.008 ± 0.003 | +0.052 ± 0.007 | Feed intake, 6 highest (Sum), RM | 0.006 ± 0.003 | +0.101 ± 0.009 |
| 16 | Conc. intake rel. deviation, RM | 0.008 ± 0.004 | −0.036 ± 0.011 | Feed intake per visit | 0.006 ± 0.003 | +0.106 ± 0.011 |
| 17 | Feeding visit duration (Mean), RMprev | 0.008 ± 0.005 | +0.034 ± 0.008 | Activity, 3 highest (Sum), RMprev | 0.006 ± 0.003 | −0.067 ± 0.011 |
| 18 | Feed intake 6 highest (Sum), RM | 0.008 ± 0.003 | +0.062 ± 0.008 | Feeding visits with intake, d-1 | 0.006 ± 0.003 | −0.068 ± 0.011 |
| 19 | Feed intake (Range), RMprev | 0.008 ± 0.005 | +0.065 ± 0.010 | Feed intake, RMprev | 0.006 ± 0.004 | +0.063 ± 0.015 |
| 20 | Feeding visits with intake, RM | 0.008 ± 0.005 | −0.057 ± 0.005 | Drinking visits, RM | 0.006 ± 0.003 | −0.059 ± 0.014 |
1 Random Forest-Importance, 2 somatic cell count, 3 rolling mean of previous week, 4 rolling mean, 5 temperature humidity index, 6 Difference of current day’s value to RM.
Mean AUC, Sensitivity and Specificity (± 95%-CI) for validation data (33% of sampled training data), means for all machine learning methods.
| Sampling of Training Data | AUC 1 | Sen. 2 | Spe. 3 |
|---|---|---|---|
| Mastitis treatments | |||
| No sampling | 0.80 ± 0.02 b | 0.72 ± 0.04 c | 0.72 ± 0.05 b |
| Random Undersampling | 0.76 ± 0.01 c | 0.81 ± 0.02 b | 0.59 ± 0.04 c |
| Random Oversampling | 0.95 ± 0.01 a | 0.89 ± 0.02 a | 0.91 ± 0.02 a |
| SMOTE 4 | 0.95 ± 0.01 a | 0.88 ± 0.01 a | 0.91 ± 0.02 a |
| Lameness treatments | |||
| No sampling | 0.76 ± 0.02 b | 0.70 ± 0.04 b | 0.68 ± 0.05 b |
| Random Undersampling | 0.71 ± 0.01 c | 0.80 ± 0.02 b | 0.53 ± 0.03 c |
| Random Oversampling | 0.91 ± 0.02 a | 0.89 ± 0.02 a | 0.84 ± 0.04 a |
| SMOTE | 0.91 ± 0.02 a | 0.87 ± 0.01 a | 0.83 ± 0.04 a |
1 Area Under ROC-Curve; 2 Sensitivity; 3 Specificity; 4 Synthetic Minority Over-sampling Technique; a,b,c superscript letters indicate significant differences at p ≤ 0.05 between sampling methods within treatments.
Figure 1Mean test data AUC (Mean ± CI) for models trained on non-sampled data. (a) Mastitis treatments; (b) Lameness treatments. Different letters indicate significant (p < 0.05) differences between classification models. AUC: Area Under ROC-Curve; ET: ExtraTrees Classifier; GNB: Gaussian Naïve Bayes; LR: Logistic Regression; RF: Random Forest; SVM: Support Vector Machine; ADA: AdaBoost; DT: Decision Tree; KNN: K-Nearest Neighbors.
Figure 2Mean test data AUC, Sensitivity, Block Sensitivity and Specificity (± 95%-CI) for each sampling method. (a) Mastitis treatments; (b) Lameness treatments. Different letters indicate significant (p < 0.05) differences between sampling methods. AUC: Area Under ROC-Curve; SMOTE: Synthetic Minority Over-sampling Technique.
Mean AUC, Sensitivity and Specificity (±95%-CI) for classification of treatments with or without inclusion of data from feed and water troughs, means include all machine learning models and sampling methods.
| Feed and Water Data Included | AUC 1 | Sen. 2 | Block Sen. | Spe. 3 |
|---|---|---|---|---|
| Mastitis treatments | ||||
| Yes | 0.67 ± 0.01 | 0.40 ± 0.02 | 0.49 ± 0.03 | 0.82 ± 0.02 |
| No | 0.66 ± 0.01 | 0.39 ± 0.02 | 0.51 ± 0.02 | 0.82 ± 0.01 |
| Lameness treatments | ||||
| Yes | 0.62 ± 0.01 a | 0.41 ± 0.02 | 0.53 ± 0.02 a | 0.76 ± 0.02 a |
| No | 0.55 ± 0.01 b | 0.38 ± 0.02 | 0.50 ± 0.02 b | 0.69 ± 0.02 b |
1 Area Under ROC-Curve; 2 Sensitivity; 3 Specificity; a,b superscript letters indicate significant differences at p ≤ 0.05 within treatments.
Mean testing data AUC, Sensitivity, Block Sensitivity and Specificity (± 95%-CI) for each classification model, averaged over all sampling methods, for mastitis and lameness treatments.
| Mastitis Treatments | Lameness Treatments | ||
|---|---|---|---|
| Classification Method | AUC 1 | Classification Method | AUC 1 |
| LR 2 | 0.75 ± 0.02 a | GNB | 0.70 ± 0.01 a |
| ET 3 | 0.75 ± 0.02 a | Soft Voting 1 | 0.69 ± 0.01 a |
| GNB 4 | 0.75 ± 0.02 a | ET | 0.68 ± 0.01 ab |
| Soft Voting 1 | 0.74 ± 0.02 a | LR | 0.68 ± 0.01 ab |
| Soft Voting 2 | 0.73 ± 0.02 a | RF | 0.67 ± 0.02 ab |
| RF 5 | 0.72 ± 0.02 ab | Soft Voting 2 | 0.66 ± 0.02 abc |
| Grid Search DT 6 | 0.69 ± 0.03 bc | SVM | 0.62 ± 0.03 bc |
| SVM 7 | 0.65 ± 0.03 c | Grid Search DT | 0.60 ± 0.02 cd |
| KNN 8 | 0.58 ± 0.02 d | KNN | 0.57 ± 0.02 de |
| Grid Search ADA 9 | 0.56 ± 0.01 d | Grid Search ADA | 0.54 ± 0.01 e |
| ADA | 0.56 ± 0.01 d | ADA | 0.54 ± 0.01 e |
| DT | 0.55 ± 0.02 d | DT | 0.54 ± 0.01 e |
1 Area Under ROC-Curve; 2 Logistic Regression; 3 Extra Trees Classifier; 4 Gaussian Naïve Bayes; 5 Random Forest; 6 Decision Tree; 7 Support Vector Machine; 8 K-nearest Neighbors; 9 AdaBoost; a, b, c, d, e superscript letters indicate significant (p < 0.05) differences between classification methods within treatments.