1. Introduction
Dry matter intake (DMI) in dairy cows is a critical indicator for feeding management and nutritional status [
1], directly influencing dairy health, productivity, and the quality and yield of dairy products [
2]. Accurate assessment of individual DMI provides valuable insights into cow health and supports informed decision-making for farmers [
3]. Therefore, monitoring cows’ foraging behavior and accurately assessing their DMI can reduce feed wastage while ensuring sufficient feed for the growth and development of cows [
4], which is of great significance for optimizing the feeding strategies of cows, enhancing feeding efficiency and fostering the sustainable development of China’s dairy industry.
Research has demonstrated that multiple factors influence the dry matter intake (DMI) of dairy cows, including physical activity, lying frequency, feeding duration, body weight, and resting time. Schirmann et al. [
5] investigated the impact of lying duration on rumination and dry matter intake (DMI) in Holstein cows. The results indicated that increased lying duration was positively associated with rumination activity, ultimately leading to higher DMI. Moreover, Pahl’s research demonstrated that both chewing time and feeding duration had a significant correlation with the dry matter intake (DMI) of dairy cows, with correlation coefficients of 0.78 and 0.89, respectively [
6], indicating strong positive relationships. The dietary concentrate-to-roughage ratio also plays a critical role in determining feed retention within the digestive tract [
7], indirectly influencing digestion efficiency and feed intake. This study incorporates these variables—including cow body weight, lying duration, lying times, rumination duration, foraging duration, walking steps, and the concentrate-to-roughage ratio in feed—into a model designed to provide accurate assessments of DMI in dairy cows. Recent studies have further demonstrated that artificial intelligence can be effectively applied to automate the extraction and classification of dairy cow behavioral data at scale. For example, Lamanna et al. [
8] employed large language models (ChatGPT-4) to extract daily time–activity budget information, including lying and rumination behaviors, from large datasets in dairy cow research. This work highlights the growing role of AI-based tools in handling complex behavioral data and supporting welfare and productivity assessment in modern dairy systems. In addition, behavioral data obtained from automated monitoring systems have also been shown to support other physiological and management-related tasks in dairy production. For example, Cavallini et al. [
9] utilized rumination and activity data derived from ear tag devices to detect pregnancy in free-range dairy cattle fed silage/hay-mix rations. This study further demonstrates that automated behavioral metrics are versatile indicators that can be leveraged for multiple aspects of dairy cow health and production management across different feeding systems.
Traditional methods for assessing individual dry matter intake (DMI) in dairy cows can be broadly classified into two categories: direct monitoring and model-based estimation. The direct monitoring method relies on electronic feeding stations to automatically identify and record cows’ feeding information, providing precise intake data. However, this approach is financially prohibitive, which restricts its scalability for large-scale implementation. Recent studies have also explored non-invasive alternatives to wearable sensors for collecting dairy cow behavioral data. For example, Giannone et al. [
10] proposed a computer vision-based framework using a YOLOv8 model to achieve automated cow identification and feeding behavior analysis without the need for physical tags. Such vision-based approaches demonstrate that key feeding-related behaviors can be captured while reducing animal stress and hardware-related costs, providing complementary solutions for intelligent behavior monitoring in dairy systems. The model-based assessment approach indirectly estimates dry matter intake (DMI) in dairy cows by constructing mathematical functions or assessment models to analyze factors influencing intake. Niderkorn and Baumont [
11] estimated DMI by modeling in vitro dry matter digestibility based on factors such as cow body weight, milk yield, and feed composition. Vazquez and Smith [
12] developed an intake assessment model from an energy perspective, incorporating relationships among basal metabolic energy, production metabolic energy, and total feed metabolic energy. While these models generally achieve high assessment accuracy, their complex parameters make analysis and processing challenging.
With the continuous development and optimization of machine learning and deep learning, these technologies have been widely applied across various fields [
13], which provide valuable insights for assessing dry matter intake (DMI) in dairy cows. Shen et al. [
14] optimized a backpropagation (BP) neural network with a decaying learning rate to evaluate DMI, comparing its performance with traditional machine learning methods and finding superior results using the BP neural network. Bezen’s study utilized deep convolutional neural networks and RGB-D cameras to achieve precise estimation of individual feed intake in dairy cows [
15]. However, neural networks often contain a large number of parameters, especially in deep networks. Limited datasets or overly complex model structures can lead to overfitting, and neural networks, as ‘black box’ models, often lack transparency and interpretability in their decision-making processes. In contrast, ensemble learning methods provide better feature importance evaluation and interpretability of the decision process [
16], offering high robustness and generalization capability, even with small datasets. Du et al. [
17] proposed a multi-feature fusion framework for rapeseed growth parameters based on the Stacking ensemble algorithm, integrating SVM, PLSR, RF, and GBDT to improve prediction accuracy, thereby advancing remote quantitative diagnostics in crop growth. Similarly, Wang et al. [
18] developed a Stacking ensemble learning model to predict rumen fermentation parameters in dairy cows and designed independent validation experiments to confirm the model’s robustness with small samples, providing theoretical guidance for optimizing dairy diets and improving feeding efficiency. Recent studies in intelligent modeling have shown that integrating advanced learning architectures or high-order feature representations can enhance robustness and predictive performance under complex and noisy data conditions. For example, DANTD combines deep learning models with high-order features to improve pattern recognition reliability in industrial Internet of Things environments [
19]. In addition, biomimetic vision-based approaches demonstrate that biologically inspired optimization strategies can effectively enhance model adaptability and robustness in complex detection tasks [
20]. Although these studies focus on different application domains, they provide valuable methodological insights for developing robust prediction models based on intelligent learning and biologically inspired optimization techniques.
In recent years, optimizing model parameters has become a research focus for improving machine learning model performance. Identifying optimal parameters is essential for achieving peak performance in specific tasks. Swarm intelligence optimization algorithms, known for their strong parallel processing capabilities and rapid convergence [
21], have become mainstream methods for model parameter optimization. Mirjalili and Lewis [
22] proposed the Whale Optimization Algorithm (WOA), inspired by humpback whale hunting behaviors. This algorithm is widely used due to its simplicity, minimal parameter adjustments, and strong ability to escape local optima. Qian’s study presents a genetic algorithm-optimized backpropagation artificial neural network (GA-BP-ANN) applied to sound quality assessment in electric vehicles, which significantly enhances the model’s assessment accuracy and generalization capability [
23]. Similarly, Xie et al. [
24], inspired by the spiral and parabolic foraging behaviors of tunas, developed the Tuna Swarm Optimization (TSO) algorithm, which features minimal parameters, robust exploratory capacity, and high optimization accuracy. TSO has been effectively applied in various fields, such as wind speed prediction, image segmentation, and solving Jensen model parameters, demonstrating notable optimization success.
Building on previous research, this study developed a model for assessing dairy cow dry matter intake (DMI) by using an improved Tuna Swarm Optimization (ITSO) algorithm to optimize a Stacking ensemble learning approach. The model’s performance was compared to that of Gradient Boosting Regression (GBR), Extra Trees Regressor (ETR), Adaptive Boosting (AdaBoost), and k-Nearest Neighbors (KNN), demonstrating its effectiveness. This model provides a scientific basis and theoretical guidance for optimizing dairy feeding structure and improving feeding efficiency.
2. Materials and Methods
2.1. Test Subjects and Data Acquisition
The study was conducted with six Holstein dairy cows, approximately 1.5 years old, selected for optimal health and physiological condition. These cows were sourced from the experimental farm at Northeast Agricultural University, located in the Acheng District of Harbin, Heilongjiang Province. The cows were involved in a 20-day experimental trial, with detailed experimental data summarized in
Table 1.
In this study, a sample is defined as a cow–day record, consisting of one day of aggregated behavioral and physiological measurements and the corresponding measured dry matter intake (DMI) for a given cow. Therefore, multiple samples originate from the same cow across different days, and observations are clustered at the animal level.
The experimental subjects were fed a diet comprising pelleted feed and hay. The formulation of the pelleted feed was as follows: 32.5% corn, 10% soybean hulls, 15% peanut shells, 8% distillers dried grains with solubles (DDGS), 15% corn gluten feed, 12% corn germ cake, 4.5% molasses, 1% limestone powder, 0.8% sodium chloride, 0.5% sodium bicarbonate, 0.5% magnesium oxide, and 0.2% vitamin and mineral premix. The cows’ feeding behavior, including parameters such as foraging duration, walking steps, lying duration, and lying times, was continuously monitored in real-time using smart collars and leg bands from the CowControl system developed by Nedap Dairy Division (Netherlands). These devices, integrated with the SarTag Neck health monitoring system, transmitted data to a server every five minutes, facilitating the aggregation of daily foraging durations and other key behavioral metrics.
During the experimental period, the cows were fed twice daily at 05:00 and 16:30. Prior to each feeding, the remaining feed in the trough was weighed. The actual feed consumption was calculated by subtracting the residual feed from the quantity initially provided during the previous feeding session. The total daily intake was determined by summing the feed consumption from both feeding times.
2.2. Data Processing
80% of the experimental dataset was used as the training set, while the remaining 20% served as the test set. Preprocessing steps were then applied to the data.
Data cleaning was first performed to ensure data integrity and reliability. Cow–day records with missing values were removed, including one record with missing walking step data and one record with missing lying duration data. These missing values were caused by temporary sensor communication interruptions or abnormal signal transmission from the wearable devices, which occasionally occur in continuous on-farm monitoring systems.
In addition, observations falling outside physiologically reasonable ranges were excluded based on prior knowledge of dairy cow behavior and practical feeding conditions. The reference ranges were determined according to the observed data characteristics summarized in
Table 1. Specifically, body weight was constrained to 380–460 kg; lying duration to 10–14 h/day; lying times to 5–20 events/day; rumination duration to 400–500 min/day; foraging duration to 5–8 h/day; walking steps to 1000–6000 steps/day; and the concentrate-to-roughage ratio to 45:55–60:40. Values outside these ranges were considered physiologically implausible under the experimental conditions. Based on these reference ranges, one cow–day record with an abnormally high walking step count (exceeding 15,000 steps/day) was identified and excluded, as this value was far beyond the typical daily activity range observed for dairy cows under the experimental conditions.
Overall, fewer than 3% of the cow–day records were removed during the data-cleaning process. As a result, the statistical characteristics and distribution patterns of the key variables before and after data cleaning remained essentially unchanged. This indicates that the data cleaning process did not selectively remove difficult samples or artificially inflate model performance.
After data cleaning, given that the multi-indicator evaluation system includes variables with different magnitudes and units, there were significant value differences among indicators. To mitigate these discrepancies, improve the model’s convergence, and enhance learning speed, Z-score normalization [
25] was applied to standardize the dataset, reducing the negative impact of dimensionality on model accuracy. The specific formula is shown below:
In this equation, denotes the mean of the population data, signifies the standard deviation of the population data, and X corresponds to the observed value for an individual datum.
This study employs Pearson correlation coefficients [
26] to analyze the correlations between variables, visually presenting the strength of associations between each feature variable and dry matter intake through a heatmap, as illustrated in
Figure 1.
2.3. Modeling
2.3.1. Stacking Ensemble Learning Approach
Ensemble learning is a widely adopted machine learning strategy designed to enhance the performance and robustness of predictive models through the integration of multiple learning algorithms [
27]. The three core approaches to ensemble learning—Bagging, Boosting, and Stacking—construct models in parallel, sequential, and hierarchical structures, respectively.
In this research, we employed a model based on the Stacking ensemble strategy, where the original dataset is divided into several subsets and fed into each base learner in the first layer, generating individual prediction. The outputs from these models are then used to train a meta-learner in the second layer, which provides the final prediction [
28]. The Stacking strategy enhances overall forecast accuracy by generalizing the outputs of various models.
In this research, a Stacking model comprising Gradient Boosting Regression (GBR), Adaptive Boosting (AdaBoost), K-Nearest Neighbors (KNN), and Extra Trees Regressor (ETR) was constructed to comprehensively assess dry matter intake (DMI) in dairy cows.
2.3.2. Base-Level Learning Component
To ensure effective ensemble learning, the base learners in the Stacking model were selected to provide complementary learning mechanisms and diverse inductive biases. In the context of dairy cow dry matter intake (DMI) assessment, the relationships between behavioral, physiological, and dietary variables are highly nonlinear and heterogeneous. Therefore, base learners with different modeling characteristics were combined to capture both global nonlinear trends and local sample-level variations.
Specifically, Gradient Boosting Regressor (GBR) and AdaBoost are boosting-based models that effectively capture complex nonlinear relationships, while k-Nearest Neighbors (KNN) preserves local data structure and performs well in small-sample settings. Extra Trees Regressor (ETR) introduces strong randomness in feature selection and split thresholds, improving robustness and reducing variance, particularly when input features are correlated. The combination of these models enhances diversity among base learners and helps reduce correlated prediction errors, which is essential for effective Stacking ensemble performance.
Gradient Boosting Regression (GBR) [
29] is an ensemble learning technique that improves predictive performance by iteratively constructing a sequence of weak learners, typically represented as decision trees. The process begins with selecting the mean of the training data as the baseline model. In each subsequent iteration, GBR predicts the residuals of the previous model by fitting a new learner, which is then integrated into the existing model. This incremental approach enables each new learner to refine the predictions by correcting the errors of its predecessor, progressively leading to a more accurate approximation of the target function.
Adaptive Boosting (AdaBoost), introduced by Yoav Freund and Robert Schapire in 1995, is an iterative algorithm designed to train a series of weak regression models on a given dataset, which are subsequently aggregated to create a robust regression model [
30]. The algorithm emphasizes data points with higher error rates from prior iterations, ensuring that these instances receive increased attention in subsequent training rounds, thereby enhancing overall learning efficacy.
At the outset of the training process, each sample is assigned an equal weight. The algorithm undergoes multiple iterations, during which a weak regressor is trained based on the current sample weights. The weight of each weak regressor is determined by its error rate on the training data; regressors that achieve lower error rates are assigned higher weights. Following this, the sample weights are adjusted, increasing the weights of misclassified samples while decreasing those of correctly classified instances. This adjustment mechanism ensures that the model focuses more on harder-to-predict samples in subsequent iterations. The final robust regression model is formed by combining all trained weak regressors, weighted by their respective importance. The iterations continue until a predefined number of cycles is completed or until further improvements in model performance become negligible.
K-Nearest Neighbors (KNN) algorithm, introduced by Thomas Cover and Peter Hart in 1967, serves as a fundamental method for classification and regression. The core principle of this algorithm is to identify the k samples in the training set that are closest to a given test instance, and then make predictions based on the majority class or mean value among these nearest neighbors. As a non-parametric algorithm, KNN makes no assumptions about data distribution, thus offering strong robustness and versatility.
To implement KNN, the first step is to select the value of k, representing the number of nearest neighbors considered for predicting an outcome [
31]. Next, a distance metric is established to quantify the proximity between unknown and known samples. In KNN, the Euclidean distance is commonly employed to measure the dissimilarity between data points. For a sample requiring prediction, the algorithm identifies the k nearest neighbors within the training dataset. Weights are subsequently assigned to these neighbors, with closer neighbors typically exerting greater influence. The final prediction for each sample is derived by computing the weighted average of the target values of its k nearest neighbors.
Extra Trees Regressor (ETR) offer an innovative ensemble learning approach that diverges from traditional random forest algorithm by incorporating sampling without replacement and introducing greater randomness in the selection of split points [
32]. These modifications aim to reduce model variance and improve robustness, making ETR particularly effective for datasets with complex patterns. The method’s core strategy involves constructing multiple decision trees, whose individual predictions are consolidated through averaging or majority voting to yield final outcomes.
2.3.3. Meta-Level Combining Component
In Stacking ensemble learning, the second layer typically employs models with robust generalization capability to identify and correct the biases present in multiple learning algorithms with respect to the training data, thereby mitigating the risk of overfitting. The random forest algorithm effectively addresses the overfitting tendency associated with individual decision trees by constructing an ensemble of trees and utilizing averaging and voting mechanisms to derive final prediction [
33]. This inherent randomness significantly enhances the model’s generalization capacity and reduces sensitivity to data noise, ultimately providing improved stability and robustness. Given these advantages, this study selects the random forest algorithm as the meta-learner in the Stacking ensemble learning model.
In this research, we have chosen GBR, AdaBoost, KNN, and ETR as the base learners for the first layer of the Stacking ensemble model. Additionally, we select RF to function as the meta-learner in the second layer. A schematic representation of the model architecture is illustrated in
Figure 2.
2.4. Model Improvement
2.4.1. Tuna Swarm Optimization
The Tuna Swarm Optimization (TSO) algorithm, introduced in 2021, is a novel swarm intelligence optimization technique. By simulating two distinct foraging behaviors of tunas: spiral foraging and parabolic foraging, it effectively optimizes target problems, demonstrating strong optimization capability and fast convergence rate.
Initialization Process:
TSO initiates the optimization process by randomly generating an initial population within the search space, as described by the following formula:
where
represents the initial position of the i-th individual,
and
are the upper and lower bounds of the search space, respectively,
is the number of tunas in the swarm, and
is a random vector uniformly distributed within
.
Spiral Foraging Process:
Tuna swarms pursue prey by forming a tight spiral, allowing each fish to follow the one ahead and thereby share and exchange information among neighboring individuals. The formula for the spiral foraging strategy is as follows:
In the TSO algorithm, denotes the position of the i-th individual at iteration t + 1, is the current best individual (food), and are weight coefficients controlling the tendency of individuals to move towards the best and the previous individual, respectively. The constant determines the extent to which tuna follow the best individual and the previous individual during the initial phase. The variables t and represent the current iteration number and the maximum iteration number, while b is a random number between 0 and 1.
When the optimal individual cannot find food, the TSO algorithm generates a random coordinate in the search space as a reference point for spiral searching. This enables the tuna swarm to explore a broader space, enhancing global exploration capability, as expressed by the following formula:
In this equation,
represents the randomly generated reference point. Typically, during the early stage of searching, the TSO algorithm engages in extensive global exploration, gradually transitioning to precise local exploration as the iteration count increases, changing the spiral foraging reference point from random individuals to the optimal individual. The final formula for the spiral foraging strategy is as follows:
Parabolic Foraging Process: In addition to spiral foraging, tuna also engage in cooperative parabolic foraging, where the swarm forms a parabolic shape with food as a reference point and searches for food by spreading out. This process is mathematically represented as:
In this context, is a random number taking values of 1 or −1 to simulate the random movement of tuna, while p decreases nonlinearly with increasing iteration count, controlling the amplitude of the search.
2.4.2. The Improved Tuna Swarm Optimization Algorithm
To address the slow initial convergence speed and the tendency to become trapped in local optima of the traditional Tuna Swarm Optimization (TSO) algorithm, this study integrates multiple strategies, including Sine–Logistic chaotic initialization, Levy flight, and Gaussian random walk, to propose an improved Tuna Swarm Optimization algorithm (ITSO).
The traditional TSO initialization process only ensures that the positions of tuna individuals remain within the upper and lower bounds; however, the distribution of tunas is random, often resulting in uneven distribution. This can lead to significant errors during the actual optimization process. To remedy this, we combine Logistic chaotic mapping (Equation (
12)) and Sine chaotic mapping (Equation (
13)) to introduce a Sine–Logistic chaotic mapping approach (Equation (
14)) for generating the initial population. This method not only enhances the diversity of the population but also enables tuna individuals to be more evenly distributed throughout the search space, thereby enhancing the algorithm’s global search capability and convergence speed. The specific formula is as follows:
In this context, represents the current state, and is a control parameter, with the optimal value determined to be .
The Sine–Logistic chaotic mapping integrates the strong ergodicity and randomness of the Logistic mapping with the uniformity and periodicity of the Sine mapping, resulting in a more uniformly distributed and diverse initial population. This significantly enhances the global search capability of the algorithm. The morphological distribution of the Sine–Logistic chaotic mapping in three-dimensional space is illustrated in
Figure 3:
During spiral foraging, if the optimal individual does not locate food, other tunas in the population will select random coordinates in the search space to follow. While this approach enhances the algorithm’s search capability to some extent, there remains a significant probability of the tuna swarm becoming trapped in local optima, hindering the discovery of the global optimum. Levy flight [
34] is a stochastic walking model that simulates certain foraging behaviors in nature and is commonly used to address continuous optimization problems. The core concept of the Levy flight strategy is to enhance the global search capability of the algorithm by mimicking movement patterns with long-tailed distributions, which allows for a higher probability of large steps during random walk. This facilitates the optimization algorithm’s ability to escape local optima, thereby improving solution quality and convergence speed. The path curves of the Levy flight strategy are illustrated in
Figure 4.
Leveraging the long-distance jumping capability of the Levy flight strategy, this study enhances the tuna swarm’s spiral foraging process. When the optimal individual in the swarm fails to locate food, other tunas update their positions based on Levy flight, thus improving the TSO algorithm’s spatial search capacity and ability to escape local optima, ultimately enhancing optimization accuracy. The specific formula is as follows:
In this context,
and
are weight coefficients that control the movement tendency of tuna individuals toward Levy flight individuals and the previous individuals, respectively.
D represents the dimensionality of the position vector,
is set to 1.5, and
u and
v follow a normal distribution as specified by the equations below.
During the parabolic foraging phase, the tuna swarm may occasionally exhibit insufficient search breadth, leading to entrapment in local optima. This issue arises because parabolic foraging primarily focuses on local search around the current best position, potentially overlooking other regions that may contain superior solutions. To address this limitation, the present study introduces a Gaussian random walk strategy [
35] during the parabolic foraging phase. By incorporating normally distributed random perturbations within the neighborhood of the current solution, this approach enhances the exploration capability of the algorithm, facilitating the escape from local optima and allowing for a broader search space exploration. This method can also improve the accuracy of the optimal solution during the later stages of the algorithm’s search process. The specific formulas are as follows:
In this formula, represents the mean, denotes the standard deviation, indicates the standard normal distribution, and D signifies the dimensionality.
In conclusion, the detailed procedure of the Improved Tuna School Optimization (ITSO) algorithm is illustrated as Algorithm 1.
| Algorithm 1 The Improved Tuna School Optimization Algorithm |
- Input:
the population size and maximum iteration
- 1:
Assign free parameters a and z - 2:
Sine-Logistic chaotic map initialization population of tunas () - 3:
while do - 4:
Calculate the fitness values of tunas - 5:
Update - 6:
for each tuna do - 7:
Update , , p - 8:
if then - 9:
Update the position using Equation ( 14) - 10:
else - 11:
if then - 12:
if then - 13:
Update the position using Equation ( 15) - 14:
else - 15:
Update the position using Equation ( 3) - 16:
end if - 17:
else - 18:
Update the position using Equation ( 21) - 19:
end if - 20:
end if - 21:
end for - 22:
- 23:
end while
- Output:
the location of food (the best individual ) and its fitness value
|
2.5. Development of a Model for Assessing Dry Matter Intake in Dairy Cows
This study employs the Improved Tuna Swarm Optimization (ITSO) algorithm to optimize the Stacking ensemble learning model. During each iteration of ITSO, the Stacking model divides the original dataset into training and testing subsets. The training subset undergoes five-fold cross-validation, where each base model splits the training data into five equal subsets and completes five training cycles. In each training cycle, four subsets are used for training, while the remaining subset is utilized for validation, producing five sets of training predictions. Concurrently, each base model generates predictions for the testing data after each training cycle. The five sets of training predictions are aggregated to serve as input for the meta-model’s training, while the average of the five testing predictions serves as the meta-model’s testing input. Based on these inputs, the meta-model produces the final prediction results. To enhance evaluation reliability and reduce the risk of overfitting, five-fold cross-validation is applied to assess the model’s performance. The optimization objective is defined as the sum of the mean squared errors (MSE) from the training and testing datasets. The ensemble process is illustrated in
Figure 5.
2.6. Model Evaluation Method
To evaluate the performance of the proposed model for assessing the dry matter intake (DMI) of dairy cows, this study employs the coefficient of determination (
), mean square error (
), mean absolute error (
), and mean absolute percentage error (
) as metrics. The formulas are defined as follows:
In these formulas, n denotes the number of experimental samples, is the true measured dry matter intake of the i-th experimental subject, is the predicted dry matter intake for the i-th subject, and is the mean of the true measured dry matter intake across all subjects in the study.
3. Results
3.1. Validation and Comparison of the Optimization Algorithms
To evaluate the optimization performance of the Improved Tuna School Optimization (ITSO) algorithm, this study conducted a comparative analysis against several swarm intelligence optimization algorithms, including Particle Swarm Optimization (PSO), Grey Wolf Optimization (GWO) [
36], Whale Optimization Algorithm (WOA), and the traditional Tuna School Optimization (TSO). For a fair comparison, the population size (N) was uniformly set to 30, and the maximum number of iterations (T) was fixed at 300 for all algorithms.
A suite of six benchmark functions, encompassing both unimodal (
,
,
) and multimodal (
,
,
) types, was selected to evaluate the algorithms. The detailed characteristics of these test functions are summarized in
Table 2. A three-dimensional visualization of these functions is given in
Figure 6.
To validate the effectiveness of the enhancements made to the Improved Tuna School Optimization (ITSO) algorithm, each optimization algorithm was independently executed on the benchmark functions. The resulting convergence plots are presented in
Figure 7.
The results clearly indicate that the Improved Tuna School Optimization (ITSO) algorithm exhibits a significant enhancement over other swarm intelligence optimization algorithms, both in terms of convergence speed and the optimal value.
3.2. Ablation Study of the Proposed ITSO Algorithm
To verify the effectiveness of the proposed improvement strategies in the ITSO algorithm, an ablation study was conducted on the selected unimodal and multimodal benchmark functions. By progressively introducing different improvement strategies, the convergence behavior and optimization performance under the same search conditions were systematically compared, allowing an in-depth analysis of the contribution of each strategy to the baseline TSO algorithm.
In the ablation experiments, the standard Tuna Swarm Optimization (TSO) algorithm was used as the baseline. Based on the three proposed improvement strategies, several algorithmic variants were constructed:
ITSOC: TSO with Sine–Logistic chaotic mapping introduced in the initialization phase;
ITSOL: TSO with Lévy flight strategy introduced in the spiral foraging phase;
ITSOG: TSO with Gaussian random walk strategy introduced in the parabolic foraging phase;
ITSO: The full improved algorithm incorporating Sine–Logistic chaotic mapping for initialization, Lévy flight in the spiral foraging phase, and Gaussian random walk in the parabolic foraging phase.
All algorithms were executed multiple times under identical parameter settings. The average convergence curves were plotted based on the experimental results to compare the optimization behaviors of different strategies. The convergence results on unimodal functions (F1–F3) and multimodal functions (F4–F6) are shown in
Figure 8.
As illustrated in
Figure 8, the ITSOC algorithm, which introduces Sine–Logistic chaotic mapping during initialization, exhibits a more stable convergence trend across different benchmark functions. The ITSOL algorithm significantly accelerates convergence in the early search stage due to the long-distance exploration capability provided by Lévy flight. In contrast, the ITSOG algorithm generally achieves higher solution accuracy in the middle and later stages of the search by enhancing local exploration through Gaussian random walk. Compared with the standard TSO algorithm, all three individual improvement strategies lead to noticeable performance improvements to varying degrees.
When all three strategies are integrated, the ITSO algorithm demonstrates further improvements in overall performance across all benchmark functions, achieving faster convergence speed and higher final solution accuracy. This indicates that ITSO possesses stronger global exploration capability in the early stage and enhanced local exploitation ability in the later stage.
In summary, the Sine–Logistic chaotic mapping, Lévy flight, and Gaussian random walk strategies each contribute positively to improving the performance of the TSO algorithm, although the effect of any single strategy is relatively limited. By synergistically integrating multiple strategies, the ITSO algorithm achieves a more balanced trade-off between search efficiency and solution accuracy, resulting in significantly improved optimization performance and stability. These results further justify the effectiveness and necessity of the proposed algorithmic enhancements.
3.3. Effect Analysis and Comparison of the Assessment Models
To validate the accuracy of the dry matter intake assessment model proposed in this study, we developed four groups of comparative models. The first group comprises classical machine learning models, including Decision Tree (DT), Random Forest (RF) and Support Vector Regression (SVR). The second group contains independent model algorithms, such as Gradient Boosting Regressor (GBR), Extra Trees Regressor (ETR), Adaptive Boosting (AdaBoost), and K-Nearest Neighbors (KNN). The third group features a Stacking ensemble model, while the fourth group includes the ITSO-optimized Stacking ensemble model. The first three groups are primarily used for comparison with the ITSO-optimized Stacking ensemble model.
The results demonstrate that the ITSO-optimized Stacking ensemble model outperforms the other models, exhibiting the best fitting and evaluation capability, with an assessment accuracy of 95.84%. The detailed evaluation results for each model are summarized in
Table 3.
The data in the table clearly indicate that the
values for the various models assessing the dry matter intake of dairy cows range from 0.8201 to 0.9584. Notably, both the Stacking model and the ITSO-optimized Stacking ensemble model significantly outperform the base learners. Compared to the best base learner, Gradient Boosting Regressor (GBR), the Stacking model improved
, Mean Squared Error (MSE), Mean Absolute Error (MAE), and Mean Absolute Percentage Error (MAPE) by 1.86%, 26.94%, 0.17%, and 0.69%, respectively. With an
value of 0.9530, the Stacking model shows increases of 3.60%, 7.79% and 2.02% over the other base learners: AdaBoost, KNN, and ETR, respectively. These results clearly demonstrate that the Stacking ensemble model achieves significant improvements across all evaluation metrics compared to the base learners. Furthermore, the ITSO-optimized Stacking ensemble model enhances the
, MSE, MAE, and MAPE by 0.57%, 11.52%, 6.66%, and 6.29%, respectively, compared to its pre-optimization performance, thereby confirming the effectiveness of the algorithm enhancements. The comparison between the predicted values of assessment models and the actual measurements is presented in
Figure 9.
To further examine the agreement between the predicted dry matter intake and the measured values, a Bland–Altman analysis was conducted on the test set for the ITSO-optimized Stacking ensemble model. The Bland–Altman plot is shown in
Figure 10.
As shown in
Figure 10, the mean difference (bias), defined as predicted minus measured dry matter intake, was −0.0616 kg/day, indicating a negligible systematic underestimation. The 95% limits of agreement ranged from −0.4575 to 0.3344 kg/day, with 23 out of 24 samples (95.83%) falling within this interval. No apparent trend was observed between the magnitude of dry matter intake and the prediction error, suggesting stable agreement across the evaluated range.
3.4. Independent Test Set Validation and Result Analysis
Experimental results indicate that the ITSO-optimized Stacking ensemble model achieved a high accuracy of 95.84% on the test set, which may raise concerns regarding potential overfitting. To further assess the model’s generalization ability and rule out the possibility of overfitting, an additional independent test set validation was conducted.
The independent test set was constructed using supplementary data collected under the same experimental conditions as the original dataset. Specifically, this dataset comprises additional samples obtained from the same group of Holstein heifers during the same 20-day experimental period at the experimental farm of Northeast Agricultural University. Although the experimental environment and sampling protocol remained consistent, all samples in the independent test set were strictly excluded from model training and initial testing, thereby serving as unseen samples for evaluating sample-level generalization performance under identical experimental conditions.
The evaluation results of the model are presented in the form of comparison plots, scatter plots, and residual plots, as shown in
Figure 11.
As shown in
Figure 11b, the data points are densely clustered around the red fitted line, indicating a strong linear correlation between the predicted and actual values. The evaluation metrics (
,
,
and
) further confirm that the ITSO-optimized Stacking ensemble model exhibits favorable assessment performance on the independent test set. Moreover,
Figure 11c demonstrates that the residuals are randomly distributed around the zero baseline and are concentrated within a narrow range (approximately [−0.4, 0.4]). The residuals are uniformly distributed across the entire range of predicted values, suggesting that the prediction errors are stable. This further indicates robust predictive behavior and stable sample-level generalization under consistent experimental conditions.
4. Discussion
4.1. Performance Comparison of Stacking Ensemble Model and Base Learners
The objective of this study was to leverage the Improved Tuna School Optimization (ITSO) algorithm to optimize the Stacking ensemble learning approach for the assessment of dry matter intake (DMI) in dairy cows. By comparing the optimized model against base learners and several widely used machine learning algorithms, we demonstrated that the optimized model is highly suitable for DMI assessment in dairy cows, exhibiting superior assessment performance.
Previous studies on DMI assessment typically involved comparing various machine learning models, selecting the most effective model based on evaluation metrics. However, each machine learning model has its own distinct strengths and limitations. The Stacking ensemble learning method, rather than relying on a single model, integrates multiple models to achieve higher performance and improved generalization capability [
37]. For instance, when AdaBoost algorithm was used to assess DMI, the coefficient of determination (
) was limited to 0.9199. Moreover, the mean squared error (MSE), mean absolute error (MAE), and mean absolute percentage error (MAPE) remained relatively high. This limitation is primarily due to AdaBoost’s iterative process of increasing the weight of misclassified samples, which amplifies the impact of noisy data on the final model. By combining AdaBoost with other machine learning algorithms, the Stacking ensemble significantly improved the
value by 3.60% and reduced MSE, MAE, and MAPE by 41.27%, 8.85%, and 8.33%, respectively, thereby greatly enhancing the accuracy of model. The meta-learner in the Stacking ensemble model leverages the strengths of multiple base learners to minimize individual weaknesses, allowing errors and limitations of each base learner to be offset by others [
18]. This methodology results in more robust and reliable assessment outcomes. Future research could explore integrating the Stacking model with additional algorithms to further refine its predictive accuracy.
Compared to traditional machine learning techniques, the Stacking ensemble model demonstrates significant advantages for small-sample datasets [
38]. It can incorporate a variety of base learners, such as decision tree and support vector machine, each capturing different characteristics of the data. The diversity of these base models enhances the ensemble model’s accuracy, particularly in scenarios with limited data. Small-sample datasets often pose a high risk of overfitting, where models perform well on training data but poorly on new, unseen data due to learning noise rather than underlying data distribution. By combining predictions from multiple models, the Stacking ensemble method reduces the sensitivity of individual models to specific datasets, thereby mitigating the risk of overfitting. Nevertheless, the most effective strategy to combat overfitting remains the collection of more comprehensive training data. Future research should focus on gathering additional data to refine the model for DMI assessment in dairy cows, thereby further enhancing its accuracy and generalization capability.
4.2. Effects of Feeding Behavior, Rumination Duration, and the Concentrate-to-Roughage Feed Ratio on Dry Matter Intake in Dairy Cows
The feeding behavior of dairy cows, including parameters such as lying duration, lying times, walking steps, and foraging duration, plays a important role in characterizing their dry matter intake (DMI). Research has shown that adequate lying duration is associated with improved rest and digestion, reduces stress, and improves overall welfare, thereby indirectly stimulating appetite and feed intake [
5]. Foraging duration is directly linked to DMI, as sufficient foraging duration ensures that cows consume enough feed to meet their nutritional needs. Conversely, frequent lying times may indicate discomfort, often related to the cow’s health or environmental conditions, which can result in reduced foraging duration and consequently lower DMI. Walking steps taken by cows is a significant indicator of their activity level; increased activity may suggest that cows are actively seeking feed or more suitable resting areas, which can influence their feeding behavior. However, excessive activity can also be a sign of stress, negatively impacting appetite and feed consumption. Zheng and Qin [
39] introduced the PrunedYOLO-Tracker, a multi-cow behavior recognition and tracking technology, which aids in monitoring the feeding behavior and activity levels of dairy cows. This technology provides valuable insights that can indirectly inform assessments of DMI.
This study investigates the effects of feeding behaviors, including lying duration, lying times, walking steps, and foraging duration, on the dry matter intake (DMI) of dairy cows. The SHAP (SHapley Additive exPlanations) values are employed to analyze the contribution of each feature variable to the model’s predicted DMI, providing an interpretation of how input features contribute to the prediction results. The results are presented in a combined format of a hive plot and feature contribution chart (
Figure 12). In this visualization, the feature contribution values (indicated by shaded boxes) and SHAP values represent the magnitude of each feature variable’s contribution to the model’s final output. The observed data distributions of key features under the experimental conditions are summarized in
Table 1.
The analysis indicates that the most significant contributor to the assessment of dry matter intake (DMI) in dairy cows is their body weight, with red points predominantly located in the positive SHAP value range. This suggests that higher body weight is associated with larger positive SHAP values, indicating a stronger positive contribution to the model output; specifically, greater body weight is associated with higher DMI. Similarly, foraging duration plays a critical role in the model’s output. When foraging duration is high, it generally contributes positively to DMI, whereas lower foraging duration tends to have a negative impact on the model’s output. This indicates that foraging duration contributes positively to the model prediction, and lower foraging duration tends to have a negative contribution. Additionally, other feeding behavior parameters, such as lying duration, lying times, and walking steps, also have a certain impact on DMI, aligning with the conclusions of this study. It should be noted that some behavioral variables are correlated; however, the overall SHAP ranking remains consistent across samples, suggesting that the main attribution patterns are stable and not dominated by a single correlated feature.
In addition to feeding behavior, factors such as the concentrate-to-roughage feed ratio and rumination duration also play a crucial role in influencing DMI. As illustrated in
Figure 12, changes in the concentrate-to-roughage feed ratio have a significant impact on DMI, consistent with findings from previous studies. For instance, Robinson et al. [
40] examined the effects of varying concentrate-to-roughage feed ratios on rumen fermentation patterns and production performance in four mid-lactation Holstein cows. Their results revealed notable differences in milk fat percentage, milk yield, and protein content depending on the feed ratio. Similarly, Shangru et al. [
41] conducted experiments to investigate the relationship between concentrate-to-roughage ratios and DMI, observing a steady increase in DMI as the concentrate proportion rose from 0% to 60%. These findings highlight the critical role of the concentrate-to-roughage feed ratio in DMI assessment research, underscoring its value as a key parameter in related studies.
Rumination duration, as a key physiological indicator for dairy cows, directly relates to their health status and nutrient absorption efficiency. Adequate rumination duration facilitates the digestion and absorption of feed; however, excessive rumination duration may indicate an overconsumption of coarse fiber feed, resulting in decreased rumination efficiency, which can encroach upon foraging duration and reduce DMI. Schirmann et al. [
5] monitored rumination duration, foraging duration, and DMI using HR-Tags and Insentec feeding stations, employing Pearson correlation coefficients for analysis. They found that longer rumination periods were associated with lower feeding times and DMI (r = −0.71, r = −0.72), indicating a negative correlation between feeding and rumination. This underscores the importance of incorporating rumination duration into DMI assessment.
In summary, this study explored the correlations between various feature variables and DMI in dairy cows, analyzing the contribution of these variables to DMI assessment. Ultimately, seven primary influencing factors were identified as inputs for the model: cow body weight, lying duration, lying times, rumination duration, foraging duration, walking steps, and the concentrate-to-roughage feed ratio.
It should be noted that, although an independent test set was used to evaluate model performance on unseen samples, the number of individual animals involved in this study was limited. Therefore, the collected dataset was primarily intended to support methodological verification of the proposed ITSO-optimized Stacking ensemble framework under controlled experimental conditions, rather than to establish a fully generalized DMI prediction model applicable to diverse herds or production systems. Further validation using larger datasets involving more animals and multiple farms is required to assess broader generalization performance.
Although the selected feature variables demonstrated good assessment performance for DMI, the study only considered a limited number of significant factors while neglecting other potential influences. Future research should comprehensively examine the factors affecting DMI to further optimize the accuracy and effectiveness of the assessment model.
5. Conclusions
This study proposes an ITSO-optimized Stacking ensemble model to assess dry matter intake (DMI) in cows, based on parameters including cow body weight, lying duration, lying times, rumination duration, foraging duration, walking steps, and the concentrate-to-roughage feed ratio. The model exhibits exceptional assessment accuracy, achieving , mean squared error (MSE), mean absolute error (MAE), and mean absolute percentage error (MAPE) values of 0.9584, 0.0384 (kg/d)2, kg/d and , respectively, significantly outperforming other models such as ETR, AdaBoost, KNN, GBR, and the conventional Stacking model. Thus, the model developed in this study provides a robust and precise tool for assessing the DMI of young, non-pregnant Holstein heifers under the experimental conditions considered. While the results demonstrate strong predictive performance within the target population, further validation using data from cows of different ages, physiological stages, and breeds is required before extending its applicability to broader dairy farming scenarios. Nevertheless, the proposed approach offers a solid theoretical basis and valuable practical insights for data-driven feeding management and future optimization of dairy production systems.