1. Introduction
In meat sheep production, timely knowledge of physiological and behavioral status is essential for animal welfare assessment, health-risk warning, feeding management, and barn environmental regulation. Precision sheep farming is increasingly supported by wearable sensors, environmental monitoring devices, and automated behavior-recognition systems, which make it possible to continuously record both animal responses and surrounding barn conditions. Recent studies have used triaxial accelerometer-based electronic devices and embedded machine-learning systems for sheep ingestive-behavior discrimination and real-time behavior classification [
1,
2]. Deep-learning and multimodal signal-fusion methods have also been applied to grazing-sheep behavior classification, spatiotemporal behavior analysis, and fattening Hu sheep behavior recognition [
3,
4]. Compared with isolated environmental readings such as temperature, humidity, gas concentration, or light intensity, animal-state indicators—including active duration, rumination duration, feeding duration, intense exercise duration, and body temperature—provide an animal-centered information layer that complements barn environmental monitoring. Because these indicators reflect behavioral allocation and physiological state, they are closely related to comfort, stress response, health status, and production management. Specifically, active duration describes general movement and activity allocation; rumination duration and feeding duration characterize ingestive and digestive behavior; intense exercise duration captures abrupt or high-intensity movement events; and body temperature reflects thermoregulatory and physiological status. Previous sheep-monitoring studies have shown that these sensor-derived behavioral and physiological indicators are closely related to feeding management, health-risk warning, welfare assessment, and environmental adaptation [
1,
4,
5,
6,
7,
8]. These indicators therefore form a practical information layer between field sensing and farm decision-making, and they are suitable targets for artificial intelligence models designed to support animal-state forecasting and management-oriented decision support in smart sheep farming.
However, farm managers do not only need to know the current state of their animals; they also need forward-looking information that can create a time window for intervention. Forecasting sheep physiological and behavioral indicators is challenging because their future trajectories may be influenced by short-term environmental exposure, previous animal-state dynamics, and routine management events, including feeding, manure cleaning, ventilation adjustment, equipment operation, and day–night rhythms [
8,
9,
10]. Previous studies have shown that environmental stressors, such as temperature–humidity variation and air-quality deterioration, can affect feeding behavior, activity patterns, thermoregulatory responses, and other physiological or behavioral states in sheep [
6,
7]. These inputs differ in sampling frequency, biological meaning, and operational context, while animal responses may involve cross-variable associations and delayed effects. Therefore, multi-step forecasting requires the joint modeling of environmental exposure, historical animal-state information, and management context, rather than relying on isolated sensor readings. Accurate multi-step forecasting can therefore help identify transitions from comfort to stress and from normal to abnormal status before they become evident in routine observation, supporting health early warning, anomaly detection, precision feeding, inspection scheduling, and environmental regulation in sheep farming [
11,
12].
Previous livestock monitoring studies have demonstrated the value of statistical and machine-learning models for converting farm data into production or welfare information. Statistical forecasting pipelines established the basis for short-term sequence prediction [
13,
14], and livestock applications used environmental and age variables to predict thermal responses [
15]. Regression and machine-learning methods have also been used to predict ammonia exposure risk, ammonia concentration, and barn temperature in livestock and poultry production [
16,
17,
18]. These approaches remain useful because of their interpretability and relatively low deployment cost, but they often depend on manually selected windows and engineered features. For continuous sheep monitoring, this limits their ability to represent cross-scale temporal dependencies, non-stationary animal responses, and interactions among environmental, physiological, behavioral, and management-related variables [
19,
20].
Recent studies in precision sheep farming have increasingly used sensor and time-series data to characterize animal behavior and welfare-related states. Sheep-specific studies have applied triaxial accelerometer-based electronic devices and embedded machine-learning systems to ingestive-behavior discrimination and real-time behavior classification [
1,
2]. Deep-learning and multimodal signal-fusion methods have also been used for grazing-sheep behavior classification, spatiotemporal behavior analysis, and fattening Hu sheep behavior recognition [
3,
4]. Related work has also explored multimodal welfare-indicator prediction in dairy sheep [
21]. However, these sheep-specific studies have mainly focused on current-state monitoring, behavior recognition, or welfare-related indicator characterization, whereas direct studies on multi-step individual-level forecasting of future physiological and behavioral indicators in meat sheep remain limited. In particular, few studies have examined how to forecast active duration, rumination duration, feeding duration, intense exercise duration, and body temperature under farm–season–barn distribution shifts [
8,
10]. Because directly comparable sheep-specific forecasting studies are still scarce, representative forecasting studies in other livestock production systems are considered only as methodological references, including sequential prediction of environmental variables in pig houses, lightweight prediction of NH
3 concentration, activity-based prediction of reproductive risk in dairy cows, and generative modeling for livestock behavior forecasting and missing-data imputation [
22,
23,
24,
25]. Taken together, these studies highlight the precise gap addressed in this work: multi-step, individual-level forecasting of sensor-derived physiological and behavioral indicators in meat sheep under domain shifts, using barn environmental exposure, historical animal-state information, and management-context data jointly.
A key difficulty in this task is that meat sheep responses should not be interpreted from environmental variation alone. Routine management and temporal context, such as feeding stage, manure cleaning, ventilation status, equipment operation, and day–night rhythm, may influence observed activity patterns and the interpretation of similar numerical fluctuations [
8,
9,
10]. Previous sheep studies have also shown that feeding-related behavior, activity patterns, and physiological responses are associated with sensor-derived behavioral information and environmental stress conditions [
1,
4,
6,
7]. For example, an increase in activity may correspond to normal post-feeding movement under one management context, whereas a similar numerical change under unfavorable thermal or barn-operational conditions may require a different welfare-oriented interpretation. Therefore, sheep-state forecasting should incorporate management context together with environmental and animal-state histories. Existing decision-support studies in precision sheep farming have emphasized that sensor readings should be interpreted together with operational background and expert knowledge, rather than as isolated values [
9,
21]. For example, increased activity may indicate a normal post-feeding response or an abnormal reaction to environmental deterioration, and elevated body temperature may reflect short-term activity or a delayed physiological response after sustained thermal load. Therefore, sheep-state forecasting should be treated as a management-context-aware precision livestock problem: the model must learn variable relationships, use farm operation information, and capture long-range cumulative and lagged responses within the same forecasting process [
26,
27].
To address this applied gap, this study proposes GCL-Sheep (Graph-Enhanced Contextual Long-Range Forecasting for Sheep Farming), an AI model for forecasting key physiological and behavioral indicators in meat sheep from multi-source farm monitoring data. The model supports multi-step prediction of active duration, rumination duration, feeding duration, intense exercise duration, and body temperature through target-specific forecasting tasks under a unified modeling strategy [
28]. GCL-Sheep uses a Cross-Variable Graph Construction (CGC) module to represent coupling between barn environmental variables and animal-state indicators, a hierarchical Domain Knowledge Prefix Encoding module (hierarchical DKPE) to include farm, season, barn, and management-event context, and a Long-Context Prediction Backbone (LCPB) to model cumulative exposure and lagged animal responses. Based on multi-scenario data organization, the model is evaluated under in-domain forecasting, Leave-One-Domain-Out cross-validation (LODO), and few-shot adaptation, so that its accuracy, robustness, and potential for deployment in new farm scenarios can be assessed [
29,
30].
The main contributions of this study are as follows:
(1) This study formulates multi-step individual-level forecasting of sensor-derived physiological and behavioral indicators in Hu sheep under farm–season–barn distribution shifts as a precision sheep farming task.
(2) This study develops GCL-Sheep, which combines domain-informed graph structure, data-driven variable association learning, hierarchical management-context encoding, and long-context temporal modeling. Compared with conventional graph-based or Transformer-based forecasting models, the proposed model explicitly integrates environmental exposure, animal-state history, and farm operation context within one forecasting framework.
(3) This study evaluates GCL-Sheep under in-domain forecasting, Leave-One-Domain-Out cross-domain testing, few-shot target-domain adaptation, ablation analysis, and sensitivity analysis, providing retrospective evidence for management-context-aware animal-state forecasting in precision sheep farming.
2. Materials, Data Collection, and Preprocessing
This section describes the farm monitoring data and preprocessing workflow used to construct forecasting samples for precision sheep farming. The data include barn environmental measurements, individual physiological and behavioral records of meat sheep, and management-context information. Because these data sources differ in sampling frequency, scale, noise level, and biological meaning, preprocessing was performed to organize farm scenarios, align temporal resolution, handle missing values and local anomalies, standardize features, and generate supervised multi-step forecasting samples while preserving the relationship between environmental exposure, animal state, and management operations.
2.1. Multi-Scenario Data Acquisition and Collection Settings
The data collection in this study covered two typical meat sheep farming environments in China, namely, Daqing in Heilongjiang Province, located in the cold northeastern region, and Aksu in Xinjiang, located in the arid northwestern region. These two sites differ substantially in climatic background, seasonal variation, barn operating conditions, and environmental control strategies, thereby providing natural distribution-shift conditions for cross-scenario modeling.
The Daqing experimental site was located at Woyuan Agriculture in Zhaozhou County, Heilongjiang Province. This farm contains 20 large-scale fattening sheep barns with a total area of 3624.31 m2, and the resting area inside each barn is equipped with bamboo slatted flooring with 13 cm spacing. In this study, two standard barns, each measuring 30 m in length and 5 m in width, were selected as monitoring targets. Each barn housed 40 Hu sheep with body weights ranging from 15 to 55 kg. This region is characterized by hot, rainy summers and extremely cold winters, with winter minimum temperatures falling below −20 °C. As a result, the thermal insulation demand is high and ventilation is substantially restricted, leading to strong seasonal variation in environmental exposure conditions.
The Aksu experimental site was located at Xincheng Agriculture in Aksu, Xinjiang, on the edge of the Tarim Basin, which is a typical warm temperate arid climatic zone. The experimental barn was a standard enclosed sightseeing sheep barn measuring 70 m in length and 9 m in width, with an overall fattening capacity of approximately 150 sheep. For individual-state monitoring, 35 Hu sheep equipped with commercial intelligent electronic ear tags were selected as key observation subjects, with an initial average body weight of 45.0 ± 2.5 kg. The electronic ear-tag system used in this study was a commercial livestock-monitoring device supplied by Zhongke Muyun Intelligent Livestock Technology Co., Ltd., (Xi’an, China), model MY-ET-S01. Each ear tag integrated an individual identification module, a triaxial acceleration sensing module, a temperature sensing module, and a wireless data-transmission module. The individual identification information was recorded through the ear-tag ID and two-dimensional code, while the triaxial acceleration and temperature signals were used by the device platform to derive individual animal-state variables, including active duration, rumination duration, feeding duration, intense exercise duration, and body temperature.
The raw motion and temperature signals were collected automatically by the ear-tag device at a nominal sensing interval of 5 min and were uploaded wirelessly to the barn-level receiving terminal through a LoRa-based communication module. The receiving terminal then transmitted the records to the cloud-based data management platform through a 4G network. According to the manufacturer’s specifications, the temperature record had a resolution of 0.1 °C and a nominal measurement accuracy of ±0.3 °C within the common physiological temperature range of sheep. The device platform exported individual-level records at an hourly temporal resolution, which were subsequently aligned with barn environmental data and management-context data. Before deployment, all ear tags were checked for ID consistency, attachment status, data-upload stability, clock synchronization, and abnormal or missing records.
This scenario is characterized by high dust exposure, pronounced diurnal temperature variations, and low air humidity. The barn was equipped with a 30 kW hot-air blower and exhaust devices to coordinate heating and ventilation demands. As shown in
Figure 1, the Daqing and Aksu experimental sites are located in the northeastern and northwestern parts of China, respectively, spanning approximately 25 degrees of longitude and 4 degrees of latitude.
To clarify the comparability of the monitored animals and farm-management conditions across sites, all monitored animals were Hu sheep raised under routine commercial fattening management. The monitored animals in both regions belonged to the fattening production stage, although the body-weight range differed between scenarios because of farm-specific production batches. During the selected monitoring periods, no large-scale disease outbreak or major abnormal veterinary intervention was recorded in the monitored barns, and records with abnormal or incomplete animal-state sequences were excluded during data-quality screening.
The two farms followed routine feeding and daily management schedules for commercial fattening sheep, but the exact diet formulation, stocking density, and environmental control operations were not forced to be identical, because the purpose of this study was to evaluate forecasting under real farm–season–barn distribution shifts. Based on barn floor area and housed capacity, the approximate space allowance was about 3.75 m2 per sheep in the monitored Daqing barns and about 4.20 m2 per sheep in the Aksu barn at its nominal fattening capacity. Therefore, breed, production purpose, monitored variable definitions, and data-collection modalities were kept comparable across sites, whereas differences in local management practice, stocking condition, diet formulation, and environmental control strategy were treated as part of the domain differences to be modeled. Time-varying management-context variables, including feeding or fasting stage, manure cleaning, vaccination, and heater, fan, or exhaust-device status, were recorded to help represent these operational differences during forecasting.
To improve the transparency of the experimental environment and monitoring configuration, representative photographs of the on-farm monitoring setup are provided in
Figure 2. These photographs show the real barn environment and pen arrangement, the installed environmental monitoring system, and the electronic ear tag used for individual sheep identification and animal-state recording. These visual materials are provided to help readers understand the animal arrangement, sensor deployment, and practical monitoring conditions used in this study.
Both experimental scenarios synchronously collected three types of data:
(1) Environmental monitoring data, including temperature, relative humidity, NH3, CO2, PM2.5, PM10, and light intensity;
(2) Individual physiological and behavioral data, including active duration, rumination duration, feeding duration, intense exercise duration, and body temperature;
(3) Management-context data, including day–night status, feeding/fasting stage, manure cleaning operations, vaccination, and the on/off status of heaters, fans, and exhaust equipment. The two scenarios were kept consistent in terms of monitoring modalities and variable definitions, thereby providing a basis for subsequent unified modeling. The monitored variables were selected to cover three complementary dimensions of precision sheep farming: barn environmental exposure, individual animal-state responses, and management-context information. This design was intended to support the joint interpretation of environmental conditions, physiological and behavioral responses, and routine production operations, rather than treating each sensor reading as an isolated numerical input. The biological, environmental, and practical management relevance of the monitored variables is summarized in
Table 1. The selection of these variables was also supported by previous studies on sheep monitoring, sensor-based behavior recognition, and environmental stress responses.
At the raw sampling level, environmental monitoring data were collected continuously at the minute scale, with original sampling intervals ranging from 1 to 5 min across scenarios. Across the original individual-level monitoring records, approximately 470,000 individual hourly records were obtained before domain screening. Among them, the five final modeling domains D1–D5 contained approximately 349,000 raw individual hourly records, whereas approximately 121,000 records from the summer and autumn portions of Dataset B were not assigned to independent modeling domains because of production-batch transition, monitoring-system adjustment, and insufficient continuity of synchronized individual ear-tag records. Environmental records and management-context records were aligned to the same hourly time index during preprocessing.
To improve reproducibility, we report the approximate number of records retained after domain screening and each preprocessing step in
Table 2. Because the final forecasting samples were generated at the individual-hour level, the table summarizes individual hourly records after quality control, missing-value processing, temporal alignment, and sliding-window generation. The supervised sample counts were calculated under the default historical lookback window
and the maximum forecasting horizon
; shorter forecasting horizons generated slightly more candidate windows.
2.2. Multi-Scenario Data Organization and Domain Construction
The integrated multi-scenario dataset consists of three original datasets, corresponding to the Daqing summer scenario, the Daqing cross-season long-term scenario, and the Aksu autumn–winter scenario, respectively. Specifically, Dataset A was collected from Barn #1 in Daqing, Heilongjiang, during June 2024–October 2024; Dataset B was collected from Barn #2 in Daqing, Heilongjiang, during March 2024–June 2025; and Dataset C was collected from Barn #3 in Aksu, Xinjiang, during September 2025–December 2025. These three datasets differ substantially in terms of geographic region, seasonal conditions, barn environmental background, and management context.
To explicitly represent distributional differences across scenarios, we organize the data into a set of domains according to the triplet farm–season–barn. A single domain is defined as follows:
where f denotes the farm or experimental site, s denotes the seasonal condition, and b denotes the barn identifier or barn source. Under this organization scheme, samples from different seasons within the same region, different barns within the same region, and different geographic regions can all be treated as independent but structurally consistent time-series domains. This data organization supports both in-domain time-series forecasting and cross-domain generalization evaluation.
After data quality screening and seasonal segmentation, the three original datasets were reorganized into five farm–season–barn domains. Although Dataset B covered a long monitoring period spanning four calendar seasons, only the winter and spring segments of Dataset B were used as independent modeling domains. The summer and autumn portions of Dataset B were not assigned to additional domains because they overlapped with production-batch transition, temporary adjustment of the monitoring system, and changes in the set of continuously tracked individual ear-tag IDs. These factors reduced the continuity of synchronized individual-state records, environmental records, and management-context logs after quality control and temporal alignment. Therefore, these segments did not satisfy the stable-cohort and continuous time-series requirements for constructing independent domain-level forecasting samples. In addition, the Daqing summer condition was already represented by Dataset A. The final modeling domains were therefore restricted to five quality-controlled farm–season–barn units.
Specifically, D1 represented the Daqing summer Barn #1 scenario from Dataset A; D2 and D3 represented the Daqing winter and spring Barn #2 scenarios from Dataset B, respectively; and D4 and D5 represented the Aksu autumn and winter Barn #3 scenarios from Dataset C, respectively. Thus, the domain definition used in this study was based on quality-controlled seasonal farm–barn units rather than raw datasets. The five domains D1–D5 were used for subsequent in-domain forecasting, Leave-One-Domain-Out cross-domain evaluation, and few-shot adaptation analysis. The detailed division of the original data sources and domain assignment is shown in
Table 3.
2.3. Temporal Alignment and Resampling
Because environmental monitoring data are typically collected continuously at the minute level, whereas individual physiological and behavioral data are mainly recorded at the hourly level, the two data types are not consistent in temporal resolution. To ensure a unified time scale while minimizing information leakage caused by frequency conversion, we do not upsample the hourly individual-level data. Instead, we use the hour as the unified temporal granularity and aggregate high-frequency environmental data into hourly features within fixed time windows.
For any environmental variable x, its mean value within the t-th hourly window is defined as follows:
where
denotes the number of observations within the t-th time window, and
denotes the i-th observation in that window. Considering that the mean alone is insufficient to fully capture environmental fluctuations and short-term disturbance characteristics, we further extract additional statistics, including the maximum, minimum, standard deviation, and end-of-window value, which together constitute the environmental feature vector for the current hour, denoted as
. The individual physiological/behavioral data and management-context data are also aligned to hourly time steps using the same temporal index, so as to ensure that environmental features, individual-state features, and contextual features can be matched on a unified time scale.
2.4. Missing-Value Processing and Feature Standardization
Due to sensor noise, network latency, equipment instability, and temporary communication interruptions, missing values and local anomalies were inevitable in the raw time-series data. To make the preprocessing procedure more transparent, the approximate missingness rate of the main variables before imputation or window removal is summarized in
Table 4. Since the final modeling samples were organized as farm–season–barn domains, the missingness statistics are reported at the domain level rather than only at the raw dataset level.
Overall, the missingness rate was relatively low for most variables. Temperature, relative humidity, light intensity, and management-context variables generally had missingness rates below 2%. Gas and particulate variables showed slightly higher missingness, especially in the Aksu domains, mainly because of dust exposure and temporary sensor or communication instability. The individual physiological and behavioral indicators derived from electronic ear tags also showed low-to-moderate missingness, mainly caused by temporary data-upload failure, loose attachment, or short communication interruptions. These statistics were used to determine whether a missing segment could be safely interpolated or whether the corresponding time window should be removed.
Different types of data were processed separately before model training. For short-term missing values in the environmental data, linear interpolation was used when the length of consecutive missing observations did not exceed two sampling points. When the consecutive missing length exceeded two sampling points but did not exceed 1 h, forward filling was applied only to preserve local continuity within the same hourly window. If the missing duration exceeded 1 h, the corresponding time window was removed. For the individual physiological/behavioral data, samples with incomplete or abnormal animal-state sequences were screened according to missing length and data continuity, so as to minimize the impact of device-related errors on supervised forecasting samples. For the management-context data, missing values were preferentially recovered based on log records, equipment states, or time-based rules; if reliable recovery was not possible, the state was marked as unknown. Because the missingness rates were generally low and long missing segments were removed rather than filled, interpolation and forward filling were used only as local corrections and were not expected to substantially alter the overall time-series structure.
In addition, because different variables vary substantially in scale and value range, directly feeding them into the model may cause the training process to be biased toward large-scale variables. To address this issue, continuous features were standardized using statistics estimated only from the corresponding training data of each experimental split. For any feature
, its standardized form is defined as follows:
where
and
denote the mean and standard deviation estimated from the training set, respectively. In the in-domain setting, these statistics were computed only from the chronological training subset within the corresponding domain and were then applied to the validation and test subsets of the same domain. In the Leave-One-Domain-Out setting, the standardization parameters were computed only from the merged source-domain training data and were then applied to the source-domain validation data and the held-out target-domain test data. The held-out target domain was never used to estimate standardization parameters. In the few-shot adaptation setting, the same source-training standardization parameters were retained, and the target-domain adaptation samples were used only for model adaptation rather than for re-estimating normalization statistics. This procedure avoids data leakage and ensures that cross-domain performance reflects generalization to unseen farm–season–barn conditions.
2.5. Supervised Sample Generation
For the multivariate time-series forecasting task considered in this study, the model input is not a static feature vector at a single time point, but a temporal window composed of multiple consecutive historical time steps. Therefore, instead of constructing additional lag features separately, we directly organize historical sequence samples using a sliding-window strategy, enabling the model to learn the temporal dependency relationships among environmental variables, individual physiological and behavioral indicators, and management context within a unified input. After temporal alignment, missing-value processing, and feature standardization, the environmental features, individual physiological/behavioral features, and management context features at each hour are concatenated to form a joint feature vector at time step t, denoted as
. On this basis, supervised learning samples are generated using a sliding-window scheme. Let
L denote the lookback window length and
H denote the forecasting horizon. Then, the input sample at time step
t is defined as follows:
The five monitored physiological and behavioral indicators were treated as target-specific forecasting tasks under a unified modeling framework, rather than as a single multi-output joint forecasting task. Let
denote the set of target indicators, corresponding to active duration, rumination duration, feeding duration, intense exercise duration, and body temperature, respectively. For each target indicator
, a separate supervised target sequence is constructed as follows:
where
denotes the future
H-step sequence of the target indicator
q. The same input feature window
, containing barn environmental features, historical animal-state indicators, and management-context variables, is used for all target-specific tasks. During model training and evaluation, each indicator is forecasted with a target-specific prediction head under the same GCL-Sheep architecture and experimental protocol. This design allows the model to use the full multi-source historical context while reporting forecasting performance separately for each physiological or behavioral indicator.
Through the above procedure, the raw multi-source heterogeneous monitoring data are uniformly transformed into supervised sample sets suitable for subsequent time-series forecasting. The organization of the preprocessed single-time-step data is illustrated in
Table 5.
Each row in the table corresponds to the single-time-step features of one meat sheep at a given hourly time step. The environmental features are used to describe the statistical characteristics of each environmental variable within the current hourly window, mainly including the mean, maximum, minimum, standard deviation, and end-of-window value of ambient temperature, relative humidity, ammonia concentration, carbon dioxide concentration, PM2.5, PM10, and light intensity. The physiological/behavioral features represent the individual state at that time step, mainly including active duration, rumination duration, feeding duration, intense exercise duration, and body temperature. The management-context features correspond to discrete state information related to farming operations, mainly including temporal rhythms, operational activities, and environmental control states. Because the actual feature dimensionality is relatively high, only a subset of representative fields is listed in the table, while the remaining variables are omitted and indicated by ellipses. At the model input stage, multiple consecutive time steps are further organized into historical sequence samples using a sliding-window strategy. For each target-specific task, one physiological or behavioral indicator over the subsequent future time steps is used as the prediction output, while the full multi-source historical feature window is retained as the model input.
2.6. Data Splitting and Evaluation Settings
After supervised sample construction, the subsequent experiments were organized from two perspectives—namely, in-domain forecasting and cross-domain forecasting—so as to simultaneously evaluate the model’s fitting ability under the same distribution and its generalization ability in unseen scenarios. Let the integrated set of multi-scenario domains be denoted as
where each domain
is jointly defined by farm, season, and barn, i.e.,
Under this organization scheme, all subsequent experiments were conducted on unified hourly sequences and a unified sliding-window sample representation.
For the in-domain forecasting setting, the samples within each domain were divided into training, validation, and test sets in chronological order, at a ratio of 7:1:2. To avoid temporal leakage, the splitting process strictly preserved the original temporal order, and no random shuffling was applied. Supervised learning windows were generated independently within each subset and did not cross the boundaries between the training, validation, and test sets. This setting was mainly used to evaluate the model’s ability to fit the variation trends of target indicators under the same farm–season–barn condition, and it was kept consistent with the subsequent multi-step forecasting experiments, lookback-window experiments, and ablation studies.
For the cross-domain forecasting setting, we adopted the Leave-One-Domain-Out (LODO) protocol. Specifically, in the
m-th experimental round, the domain
was selected as the target-domain test set, while the remaining
domains were merged to form the source-domain sample set:
The model was trained and validated using only the source-domain data, without using any target-domain samples for parameter updating. After training, the model was directly applied to the target domain for testing, so as to evaluate its transferability under unseen farms, unseen seasons, or unseen barns. This setting provides a stricter test of whether the model has learned transferable environment–animal-state association patterns across scenarios, rather than merely relying on local statistical patterns from a single scenario.
During source-domain training, to ensure the stability of model selection and early stopping, the source-domain samples were further split into training and validation sets in chronological order. The validation set was used for early stopping, parameter selection, and hyperparameter tuning. For target-domain testing, all samples remained completely independent and were used only for final performance evaluation. Unless otherwise specified, the subsequent cross-domain experiments report the average results over all LODO rounds, so as to reduce the randomness caused by any single target-domain split.
In addition, to simulate the practical situation in which only a small amount of target-domain observational data is available during the early deployment stage of a new scenario, we further introduced a few-shot target-domain fine-tuning setting in addition to zero-shot cross-domain testing. For each LODO round, the model was first trained using only the source-domain data, without using any target-domain samples. Then, the chronologically earliest 5%, 10%, or 20% of the held-out target-domain supervised samples were used as the adaptation set. The remaining later samples from the same target domain were used only for testing. The adaptation samples were strictly excluded from the test set, and supervised windows were generated independently within the adaptation and test subsets so that no sliding window crossed the adaptation–test boundary.
During few-shot target-domain fine-tuning, the model was initialized with the source-domain trained parameters from the corresponding zero-shot LODO round and then updated on the target-domain adaptation set using a smaller learning rate and a limited number of fine-tuning epochs. All trainable parameters of GCL-Sheep, including the data-driven graph parameters, hierarchical context-encoding parameters, long-context backbone, and prediction head, were updated during fine-tuning, whereas the predefined static prior graph topology was kept unchanged. The held-out target-domain test samples were not used for parameter updating, stopping, or model selection. Because fine-tuning started from the trained source-domain model and used only 5%, 10%, or 20% of the target-domain samples, the computational cost was much lower than that of training a new model from scratch.
Through the above three settings—namely, in-domain forecasting, zero-shot cross-domain forecasting, and few-shot target-domain fine-tuning—this study systematically evaluated the predictive accuracy, cross-scenario transferability, and limited-data adaptation ability of GCL-Sheep for forecasting key physiological and behavioral indicators in meat sheep.
2.7. Rationale for Preprocessing and Experimental Settings
The main preprocessing and experimental settings were determined by combining the characteristics of the monitoring devices, time-series forecasting requirements, preliminary data-quality inspection, and the biological and practical relevance of the monitored variables. First, an hourly temporal granularity was adopted because the individual physiological and behavioral records exported by the electronic ear-tag platform were organized as hourly records, whereas the environmental variables were originally collected at a higher frequency. Aggregating environmental measurements to hourly statistics avoided artificial upsampling of individual animal-state records and provided a unified temporal scale for environmental exposure, animal response, and management-context information.
Second, the missing-value processing rules were designed according to the raw sampling frequency and the continuity of environmental changes. Short gaps in environmental records were regarded mainly as temporary sensor or communication interruptions and were corrected by linear interpolation when no more than two consecutive observations were missing. For gaps longer than two sampling points but not exceeding 1 h, forward filling was used only to preserve local continuity within the same hourly window. Time windows with missing durations longer than 1 h were removed because they could no longer reliably represent the corresponding hourly environmental exposure. For individual physiological and behavioral records, samples with incomplete or abnormal animal-state sequences were screened to avoid propagating device-related errors into the supervised forecasting samples.
Third, the temporal-window settings were selected to balance biological interpretability, forecasting demand, and computational cost. The forecasting horizons of 1, 3, 6, and 12 h were used to represent short-term and medium-term early-warning intervals that are relevant for barn inspection, ventilation adjustment, feeding management, and targeted intervention. The default lookback window was set to 96 h after preliminary validation and sensitivity analysis, because this range covers multiple day–night cycles and provides sufficient historical context for delayed animal responses without introducing excessive redundant information.
Fourth, the chronological data-splitting strategy was adopted to avoid temporal leakage. In the in-domain setting, training, validation, and test sets were separated according to temporal order, and sliding windows were generated independently within each subset. In the cross-domain setting, the Leave-One-Domain-Out protocol was used to evaluate whether the model could generalize to unseen farm–season–barn conditions. These settings were chosen to better approximate practical deployment, where future samples and new farming scenarios are not available during model training.
Finally, the monitored physiological and behavioral variables were selected according to their availability from the ear-tag platform and their relevance to sheep welfare and production management. Active duration, rumination duration, feeding duration, intense exercise duration, and body temperature provide complementary information on activity allocation, ingestive behavior, abnormal movement, and thermoregulatory status. Previous studies on sheep monitoring, sensor-based behavior recognition, and environmental stress responses have also shown that these types of behavioral and physiological indicators are closely related to welfare assessment, feeding behavior, health status, and environmental adaptation [
1,
2,
4,
6,
7,
8,
10].
5. Discussion
5.1. Joint Modeling of Environmental Exposure, Management Context, and Meat Sheep State Dynamics
The three core modules of GCL-Sheep should be interpreted as complementary parts of an animal-state forecasting workflow rather than as independent algorithmic additions. The practical difficulty is that future physiological and behavioral indicators may be associated with environmental exposure, animal-history information, management context, and delayed temporal patterns in the monitoring data. CGC, DKPE, and LCPB therefore correspond to three farm-facing modeling requirements: representing environment–animal-state associations, incorporating management background, and using extended historical information for multi-step forecasting.
This interpretation is consistent with previous studies in precision sheep farming and livestock environmental physiology. Sensor-based sheep-monitoring studies have shown that activity-, feeding-, rumination-, and body-temperature-related variables can provide useful information for welfare and health-state assessment [
1,
2,
4,
5,
8]. In addition, environmental physiology and livestock-house air-quality studies have reported that thermal conditions, ammonia exposure, and particulate matter are associated with feeding behavior, rumination-related activity, respiratory response, thermoregulation, and other behavioral or physiological changes in sheep or sheep–goat housing systems [
6,
7,
37,
38]. Therefore, the present discussion interprets the model components as forecasting-oriented representations of these known monitoring dimensions, rather than as experimental proof of new biological mechanisms.
CGC contributes by reorganizing multi-source monitoring variables according to domain-informed associations that are relevant to animal-state forecasting. If environmental, physiological, and behavioral variables are simply concatenated, the model may learn local correlations but may not sufficiently separate domain-informed variable associations from incidental co-fluctuations in a specific barn or season. By integrating prior topology with data-driven adjacency relationships, CGC helps the model represent associations among barn environment, animal-state indicators, and behavioral outputs in a structured way. This should be understood as a forecasting-level representation strategy, not as direct evidence of causal biological pathways.
DKPE contributes by adding the operational background under which numerical changes occur. In real sheep farms, changes in activity, rumination, feeding duration, or body temperature may occur under different management contexts, such as feeding, manure cleaning, ventilation adjustment, day–night transition, or heating operation. Previous decision-support studies in precision sheep farming have also emphasized that sensor readings should be interpreted together with operational background and expert knowledge, rather than as isolated values [
8,
9,
10,
21]. Accordingly, DKPE should be interpreted as a way to provide management-context information to the forecasting model, rather than as evidence that the model fully understands the biological meaning of each behavioral fluctuation.
LCPB contributes by modeling longer temporal contexts in which environmental variation, management events, and animal-state indicators may show delayed statistical associations. A short-window model is more likely to focus on local fluctuations, whereas long-context modeling can include day–night rhythms, repeated management events, and cross-day environmental variation. Because LCPB receives representations already informed by variable relationships and management context, it may better capture delayed temporal associations between environmental variation and future animal-state indicators. This interpretation is consistent with the lookback-window and exploratory lag-correlation analyses reported in the Results section, but it should not be interpreted as direct proof of a specific physiological lag mechanism.
The ablation results provide forecasting-level support for this interpretation. Removing CGC reduced the benefit of graph-based variable representation, removing DKPE reduced the benefit of management-context information, and removing the key long-context design in LCPB weakened the model’s ability to use extended historical information. These degradations indicate that the performance gain is associated with the coordinated use of structural, contextual, and temporal information for the same animal-state forecasting task, rather than with a single component alone.
In practical terms, GCL-Sheep converts heterogeneous farm monitoring records into forecasts that are more closely aligned with animal-state monitoring needs. The model not only extrapolates a target sequence but also uses environmental measurements, management background, and cross-day temporal information to support context-aware forecasting of future sheep behavior and physiological indicators. The discussion of these components is therefore intended to explain their contribution to forecasting performance and farm decision support, rather than to claim direct validation of biological mechanisms.
5.2. Implications for Precision Monitoring and Proactive Management in Meat Sheep Farming
The main practical significance of this study is that it shifts the focus of smart sheep farming from monitoring barn conditions alone toward forecasting future animal-state indicators. Environmental variables such as temperature, humidity, ammonia concentration, carbon dioxide concentration, and particulate matter describe barn exposure conditions, whereas active duration, rumination duration, feeding duration, intense exercise duration, and body temperature describe animal-state responses that are more directly connected to welfare monitoring and management needs. This application-oriented interpretation is consistent with previous reviews and decision-support studies in precision sheep farming and precision livestock farming [
8,
9,
10,
21].
The model outputs should therefore be interpreted as decision-support information rather than as direct diagnostic conclusions. By jointly using environmental measurements, individual historical states, and management events, GCL-Sheep provides future estimates that may help identify abnormal trends, potential health-risk signals, or management periods requiring attention. For farm use, such forecasts may support prioritization of ventilation adjustment, thermal regulation, feeding arrangement, inspection scheduling, and targeted observation. However, these outputs should complement, rather than replace, direct animal observation, veterinary judgment, and established welfare assessment protocols.
The multi-step nature of the forecasts is potentially relevant for proactive management. The forecasting results and exploratory lag-correlation analysis suggest that animal-state indicators may contain useful delayed temporal information under environmental and management changes. When the model maintains performance at longer forecasting horizons, it may provide a useful management window for earlier inspection, environmental adjustment, or targeted observation. However, this should be interpreted as retrospective forecasting evidence rather than as validation of a real-time early-warning or intervention system. Further field validation is still needed before defining practical intervention thresholds.
The LODO cross-domain and few-shot adaptation results further suggest deployment potential in new farming scenarios. Actual sheep farms differ in climate, barn structure, sensor configuration, stocking density, and management rhythm, so a model that performs well only in one scenario may have limited practical value. In this study, GCL-Sheep maintained useful transfer performance across unseen farm–season–barn domains, and its performance improved after introducing a small amount of target-domain data. This indicates that the learned variable-association and management-context representations may support low-cost adaptation when the model is introduced into a new farm. Nevertheless, the present evaluation was conducted retrospectively using historical monitoring data, and no real-time system deployment, online model updating, farmer-facing alert interface, or farmer intervention trial was conducted in this study. Therefore, broader multi-region validation and prospective deployment tests are still required.
Several practical issues still need attention before routine deployment. Sensor failures, missing records, changes in management workflow, differences in stocking density, and farm-specific decision thresholds may affect how forecasts are used in practice. Future on-farm validation should therefore connect model outputs with explicit early-warning thresholds, welfare assessment protocols, farmer feedback, and intervention records. Such validation would help determine how animal-state forecasts can be integrated into daily farm management, how alerts should be presented to farmers, and how much human oversight is required for reliable decision support.
6. Conclusions
This study developed GCL-Sheep, a management-context-aware forecasting model for predicting key physiological and behavioral indicators in Hu sheep using multi-source farm monitoring data. By integrating barn environmental measurements, historical animal-state records, and management-context information, the model provides multi-step forecasts of active duration, rumination duration, feeding duration, intense exercise duration, and body temperature. The purpose of the framework is to provide forward-looking animal-state information for management-oriented decision support in precision sheep farming, rather than to directly diagnose welfare or health status.
The main evidence shows that GCL-Sheep achieved promising retrospective forecasting performance compared with XGBoost, LSTM, TCN, Transformer, PatchTST, and Time-LLM under the in-domain setting, with clearer advantages at longer forecasting horizons. For active-duration forecasting at , the model reduced the MAE and RMSE by 20.0% and 19.2%, respectively, compared with the second-best baseline, and it improved by 0.079. The lookback-window experiment indicated that a 96 h historical window provided a favorable balance between prediction accuracy, temporal coverage, and computational cost. In addition, the Leave-One-Domain-Out and few-shot target-domain fine-tuning results suggest that the model has potential for cross-scenario forecasting and limited-data adaptation under new farm–season–barn conditions.
Overall, this study contributes an applied AI workflow for transforming heterogeneous farm monitoring records into sensor-derived animal-state forecasts. The results support the value of jointly using environmental exposure, historical animal-state information, and management context for multi-step forecasting in precision sheep farming. However, the present study evaluated retrospective predictive accuracy only. It did not validate welfare-threshold-based early warning, clinical diagnosis, real-time deployment, or farmer intervention outcomes. Therefore, the model outputs should be regarded as decision-support information that may assist in inspection scheduling, environmental adjustment, and targeted observation, rather than as direct diagnostic or welfare-intervention conclusions.
Several limitations remain. First, the number and diversity of available farm–season–barn domains are still limited, and broader external validation across independent farms, regions, seasons, breeds, and management systems is needed. Second, several analyses used active duration as the representative target indicator, while other physiological and behavioral indicators may differ in noise level, temporal regularity, event sparsity, and forecasting difficulty. Third, the full raw farm-monitoring data have limited accessibility because they contain farm operation records and individual animal monitoring information. To support reproducibility, future work should provide code, model configurations, preprocessing scripts, trained-model settings, and anonymized or representative sample-generation templates where permitted by data-sharing agreements. Finally, practical deployment still requires prospective field trials with explicit early-warning thresholds, welfare assessment protocols, farmer feedback, and intervention records. Future work should therefore focus on larger multi-region datasets, individual-difference analysis, more fine-grained multi-indicator forecasting, interpretable decision rules, and real-farm deployment tests under routine management conditions.