Next Article in Journal
Melatonin Rescues Triclosan-Disrupted Porcine Oocyte Meiosis via Suppression of p53-Mediated Apoptosis
Previous Article in Journal
Lipidomics Techniques Revealed the Adipogenic Differentiation Mechanism of Bovine Adipose-Derived Neural Crest Stem Cells
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

A Patch and Attention Mechanism-Based Model for Multi-Parameter Prediction of Rabbit House Environmental Parameters

1
College of Information and Electrical Engineering, China Agricultural University, Beijing 100083, China
2
State Key Laboratory of Animal Nutrition and Feeding, College of Animal Science and Technology, China Agricultural University, Beijing 100093, China
*
Author to whom correspondence should be addressed.
Animals 2025, 15(21), 3192; https://doi.org/10.3390/ani15213192
Submission received: 27 September 2025 / Revised: 30 October 2025 / Accepted: 31 October 2025 / Published: 2 November 2025
(This article belongs to the Section Animal System and Management)

Simple Summary

Accurate prediction of temperature, humidity, and carbon dioxide concentration inside rabbit houses makes it possible to regulate the environment more precisely, which improves housing conditions and ultimately enhances the health and productivity of rabbits. To improve prediction accuracy and cross-regional generalization, a multi-parameter prediction model for rabbit houses is proposed, integrating patching and attention mechanisms. The model employs differentiated encoding strategies for environmental and auxiliary parameters, substantially enhancing its multi-parameter modeling capabilities. Experimental results indicate that the model achieves superior predictive accuracy and strong cross-regional generalization, supporting intelligent environmental regulation in intensive rabbit farming.

Abstract

The health and productivity of rabbits are highly sensitive to the environmental conditions within the rabbit house, particularly to fluctuations and deviations in temperature, relative humidity, and carbon dioxide (CO2) concentration. However, owing to the thermal inertia and residual evaporation effects inherent in ventilation and cooling systems, environmental changes often exhibit delayed responses, rendering real-time control inadequate. Accurate prediction of key environmental parameters is indispensable for formulating effective environmental control strategies, as it enables consideration of their future dynamics and thereby enhances the rationality of regulation in rabbit farming. Existing prediction models often exhibit unsatisfactory accuracy and weak generalization, which restricts the incorporation of prediction into effective environmental control strategies. To address these limitations, summer indoor and outdoor environmental data were collected from rabbit houses in Nanping, Fujian; Jiyuan, Henan; and Qingyang, Gansu, China—three climatically distinct regions—forming three datasets. Based on these datasets, a multi-parameter time-series prediction model, Patch and Cross-Attention Enhanced Transformer for Rabbit House Prediction (PatchCrossFormer-RHP), is introduced, integrating patching and attention mechanisms. The model partitions the sequences of rabbit house temperature, relative humidity, and CO2 concentration into patches and incorporates auxiliary parameters, such as indoor air velocity and outdoor temperature and humidity, to enhance feature representation. Furthermore, it applies cross-attention with differentiated encoding to disentangle multi-parameter relationships and improve predictive performance. This study used the Fujian dataset as the primary benchmark. On this dataset, PatchCrossFormer-RHP achieved root mean square error (RMSE) values of 0.290 °C, 1.554%, and 38.837 ppm for rabbit house temperature, humidity, and CO2 concentration, respectively, with corresponding R2 values of 0.963, 0.956, and 0.838, consistently outperforming RNN, GRU, and LSTM. Transfer experiments with single- and multi-source pretraining followed by fine-tuning on Fujian demonstrated that strong cross-regional generalization can be achieved with only limited target-domain data.

1. Introduction

In recent years, large-scale rabbit farming in China has experienced rapid development. From 2021 to 2023, the rabbit industry index continued to rise, and rabbit meat production reached 458,000 tons in 2023 [1]. Intensive farming systems contribute to the sustainable development of the rabbit industry. However, under enclosed and high-density conditions, improper regulation of environmental factors—such as temperature, humidity, and harmful gases—can easily induce stress responses and diseases, thereby impairing rabbit growth and development [2,3,4]. The core of intelligent environmental regulation systems in rabbit houses lies in the control algorithm, which dynamically adjusts the operating states of fans, cooling pads, and heaters according to real-time environmental parameters to maintain optimal housing conditions. Existing algorithms typically rely only on current parameter values and lack the ability to anticipate future trends, often resulting in insufficient regulation accuracy [5,6,7]. However, environmental regulation in rabbit houses often exhibits time-lag effects caused by thermal inertia and residual evaporation, which delay the system’s response to control actions. These lag characteristics make real-time control insufficient, highlighting the necessity of predictive modeling to anticipate and compensate for environmental fluctuations. In addition, integrating prediction results with control algorithms enables proactive adjustment of ventilation, cooling, heating, and other components of the environmental regulation system, thereby improving overall stability and efficiency. Therefore, accurate prediction of indoor environmental parameters is essential for designing and implementing effective regulation strategies, improving control precision, and ultimately enhancing rabbit comfort and animal welfare [8,9].
Prediction models for livestock and poultry housing environments can be broadly categorized into physics-based statistical models, machine learning models, and deep learning models. Physics-based statistical models rely heavily on precise experimental data and extensive domain expertise, making them challenging to construct and limiting their transferability [10,11,12]. Machine learning models, such as those based on support vector regression (SVR) [13] and extreme learning machines (ELM) [14], adopt data-driven approaches to capture the coupling relationships among environmental variables, thereby enhancing model applicability and flexibility. However, these models remain highly dependent on data quality, while livestock housing data are often susceptible to noise interference. Both physics-based and machine learning models show limited capability in feature extraction and nonlinear modeling. By contrast, deep learning models, with their powerful capabilities for automatic feature learning and nonlinear modeling, have emerged as a key research direction for predicting environmental parameters in livestock housing [15,16,17,18,19,20,21,22]. For instance, Lee [22] employed recurrent neural networks (RNNs) to predict temperature and humidity in duck houses under different ventilation modes. Li [21] compared RNN, LSTM, and GRU for predicting dissolved oxygen in fish ponds, demonstrating that LSTM and GRU achieved superior performance, with GRU requiring fewer parameters. Liu [23] further demonstrated that Transformer-based models achieved higher accuracy and stability than mainstream architectures, such as BERT and Seq2Seq, in rabbit house environmental prediction tasks.
However, the strong interdependence among environmental factors in livestock and poultry houses makes it challenging to ensure prediction accuracy. Feng [24] applied principal component analysis (PCA) to reduce the number of environmental parameters in sheep houses, which effectively improved prediction accuracy. Yang [25] proposed an empirical mode decomposition (EMD)-based model for predicting ammonia concentration in pig houses, enhancing both accuracy and efficiency. Ji [26] employed the seasonal-trend decomposition procedure (STL) to decompose rabbit house environmental sequences into trend, seasonal, and residual components, thereby partially addressing the problem of variable coupling. These studies primarily focused on data preprocessing and feature extraction, showing that sequence decomposition can improve predictive accuracy. Nevertheless, when applied to different regions or different types of livestock housing, the generalization ability of existing models remains limited. In particular, there is a lack of discussion on cross-regional deployment and insufficient analysis of model adaptability for heterogeneous housing environments.
In summary, rabbit house environment prediction faces challenges, such as limited accuracy and generalization in multi-parameter and multi-step forecasting, and a lack of research on cross-regional model deployment. To address these challenges, this study aims to develop a unified prediction framework, termed PatchCrossFormer-RHP (Patch and Cross-Attention Enhanced Transformer for Rabbit House Prediction), by enhancing Transformer-based architectures through the integration of patch-based temporal encoding and a cross-attention mechanism. This framework is designed to achieve high-precision and generalizable forecasting of key indoor environmental parameters—temperature, relative humidity, and CO2 concentration—in rabbit houses across different regions.

2. Materials and Methods

2.1. Data Collection

Environmental parameters were collected from three enclosed rabbit houses located in Qingyang (Gansu, China), Jiyuan (Henan, China), and Nanping (Fujian, China). These farms are situated in distinct climatic zones, representing the northwest arid, central temperate, and southeastern humid regions of China’s rabbit-farming areas. Each site was an intensive rabbit house with clear environmental regulation needs, selected to ensure data representativeness and reliability. This inter-regional design emphasizes climatic diversity to validate the model’s cross-regional transferability.
Table 1 summarizes the characteristics of the rabbit houses, and Figure 1 illustrates the housing conditions.
In addition to indoor sensors, outdoor sensors were mounted on shaded exterior walls to record air temperature and humidity. These parameters serve as external drivers influencing indoor thermal and moisture dynamics. The same type and number of sensors were installed in all three rabbit houses. The sensor specifications are listed in Table 2.
To ensure that the collected data accurately reflected the actual environment of the rabbit houses, the sensors inside the houses were arranged as shown in Figure 2.
The data collection periods were as follows: Nanping, Fujian (1 August–30 September 2023); Qingyang, Gansu (25 July–30 September 2023); and Jiyuan, Henan (12 August–30 September 2023). Summer was chosen as the sampling period because it represents the most heat-stress-prone season, when environmental regulation faces the highest demand for intelligent control. The sampling frequency was set to once per minute.

2.2. Data Preprocessing

During data collection, occasional sensor errors resulted in localized anomalies, manifested as abnormally high or low values at specific time points. To address this, outlier detection was first performed using a sliding-window method to identify abnormal points, which were then marked and set as null values. Additionally, data loss occurred due to external factors, including network failures or temporary power outages. For these outliers and missing values (with missing durations not exceeding 60 min), linear interpolation was uniformly applied for imputation. The calculation method of linear interpolation is given in Equation (1):
y k = y 1 + k n + 1 y 2 y 1 , k = 1,2 , , n
y 1 , y 2 represent the nearest valid values before and after the missing interval, respectively. n denotes the total number of missing values, and y k represents the interpolated value for the k -th missing data point.
The sampling frequency was set to once per minute, while the environmental parameters in rabbit houses generally exhibited slow variation. To improve model performance, a sliding-average method was applied for down-sampling, adjusting the data interval to 10 min. This process effectively smoothed local fluctuations in the sequences and aligned better with practical requirements for control and decision-making.
To eliminate the effects of dimensional differences among environmental parameters and to accelerate model convergence, the data were normalized using the min–max method, as defined in Equation (2):
x s c a l e d i = x i x m i n i x m a x i x m i n i + 10 7
x s c a l e d i denotes the normalized value of the environmental parameter x i , while x m i n i and x m a x i represent the minimum and maximum values of the i -th parameter, respectively.

2.3. Data Analysis

The environmental parameters in rabbit houses exhibit nonlinear, non-stationary, periodic, and strongly coupled characteristics [27]. Based on a detailed comparative analysis of the environmental features and differences across the three regions during the sampling period, data from one representative week (20–26 August 2023) were selected for illustrative presentation. This period corresponds to the late summer season, one of the most complex transitional phases of the year, during which climatic differences among the three regions are most pronounced. For each region, the outdoor temperature and humidity data collected during this week were aligned by time points. The mean values of the observations at the same time points across seven days were calculated, and their maximum, minimum, and diurnal ranges were further derived. The results are presented in Table 3.
It can be observed that notable differences exist in the outdoor temperature and humidity among the three regions. In Nanping, Fujian, both daytime temperature and humidity were higher than those in Qingyang, Gansu, and Jiyuan, Henan, with smaller diurnal variations. Qingyang, Gansu, recorded the lowest temperature and humidity, accompanied by pronounced diurnal fluctuations. The conditions in Jiyuan, Henan, were intermediate between those of Fujian and Gansu, showing relatively strong variability.
Similarly, the seven-day mean variation curves of indoor temperature, humidity, and CO2 concentration for the three regions were computed, and the results are illustrated in Figure 3.
As shown in Figure 3, the temperature and humidity in the Fujian rabbit house were significantly above the optimal ranges (the recommended environmental temperature for rabbits is typically 15–25 °C, and the optimal relative humidity is 60–65% [28]), indicating a potential risk of heat stress. In contrast, the Gansu rabbit house maintained temperatures close to the suitable range but exhibited large diurnal fluctuations, while CO2 concentrations remained persistently high, suggesting insufficient nighttime ventilation. The Henan rabbit house exhibited intermediate temperature and humidity levels compared to the other two sites, with relatively high variability. Overall, the three rabbit houses displayed marked differences in their environmental parameters.
To evaluate the coupling strength and structural differences among different parameters, Pearson correlation coefficients were calculated for all environmental variables. The correlation heatmaps of rabbit house parameters in the three regions are presented in Figure 4.
It can be observed that indoor temperature, indoor humidity, and indoor CO2 concentration were strongly coupled with each other, while indoor wind speed, outdoor temperature, and outdoor humidity exerted significant influences on these three indoor parameters. Moreover, the correlations among environmental variables varied across the three regions. The coupling was strongest in Fujian, whereas the parameters in Gansu appeared relatively independent of each other. These differences can be attributed to regional variations in climate conditions, housing structures, stocking densities, management practices, and environmental control systems.

2.4. Predictive Model Construction

Based on the analysis of environmental parameters in rabbit houses and considering the coupling relationships among variables, we propose PatchCrossFormer-RHP (Patch and Cross-Attention Enhanced Transformer for Rabbit House Prediction) to improve prediction accuracy, stability, and model generalization.
PatchCrossFormer-RHP adopts a modeling strategy that integrates both temporal and channel dimensions. The model input is divided into two parts: the environmental parameter sequence and the auxiliary parameter sequence. The environmental parameter sequence includes indoor temperature, indoor humidity, and indoor CO2 concentration, while the auxiliary parameter sequence consists of indoor wind speed, outdoor temperature, and outdoor humidity. The model outputs are the predicted sequences of indoor temperature, humidity, and CO2 concentration.
PatchCrossFormer-RHP consists of an embedding layer, an encoder layer, and a prediction layer. The overall architecture is illustrated in Figure 5.

2.4.1. Embedding Layer

The embedding layer encodes the input environmental and auxiliary parameter sequences, projecting them into continuous vector representations that serve as inputs to subsequent modules.
In time-series forecasting models, two primary encoding strategies are commonly used: time dimension encoding and channel dimension encoding. These approaches enhance the model’s ability to capture temporal dynamics from different perspectives. Time dimension encoding improves the model’s sensitivity to local trends (e.g., short-term fluctuations) and global patterns (e.g., long-term cycles) within sequences. In contrast, channel dimension encoding captures the coupling relationships among different input variables. PatchCrossFormer-RHP adopts a modeling strategy that integrates both encoding types.
The model receives three environmental parameter sequences X and four auxiliary parameter sequences S, as defined in Equations (3) and (4):
X = { x 1 , x 2 , x 3 }
S = { s 1 , s 2 , s 3 }
x i , s i R N , x 1 , x 2 and x 3 represent indoor temperature, indoor humidity, and indoor CO2 concentration, respectively, while s 1 , s 2 and s 3 correspond to indoor wind speed, outdoor temperature, and outdoor humidity. N denotes the sequence length.
The environmental parameter sequence X is encoded using a patching strategy. Each sequence is divided into k non-overlapping patches of equal length. The value of k is determined according to Equation (5):
k = N L ,
N denotes the sequence length and L represents the patch length. Both the k patches of x i and the original sequence x i are encoded separately to capture local and global temporal features, respectively. The encoding process is illustrated in Figure 6.
This patch-based encoding strategy facilitates the extraction of sufficient intra-sequence information while preserving global sequence characteristics. It helps the model capture both local trends (e.g., short-term fluctuations) and global patterns (e.g., periodic variations) within the sequence.
The embedded and encoded environmental parameter sequence is denoted as X e n , as shown in Equation (6):
X e n = { X e n 1 , X e n 2 , X e n 3 } ,
X e n 1 , X e n 2 and X e n 3 represent the embedded and encoded sequence vectors of indoor temperature, indoor humidity, and indoor CO2 concentration, respectively.
The vector X e n i contains k + 1 encoded vectors, corresponding to the encoded subsequences and the full sequence, as shown in Equation (7):
X e n i = { p 1 , p 2 , , p k , p G } ,
vector X e n i contains both local and global information of the original sequence.
Each sequence s i in the auxiliary parameter sequence S is encoded along the channel dimension (Equation (4)).
In this study, sinusoidal positional encoding is adopted. As an effective encoding strategy for Transformer-based long-sequence prediction models, sinusoidal positional encoding enables the model to capture both local trends and global patterns in time series data without introducing additional trainable parameters. The computation of the sinusoidal positional encoding is given in Equations (8) and (9):
p ( p o s , 2 i ) = s i n p o s 10000 2 i / d ,
p ( p o s , 2 i + 1 ) = c o s p o s 10000 2 i / d ,
pos denotes the time step, i denotes the dimension index, and d represents the embedding dimension.

2.4.2. Encoder

The encoder is responsible for extracting temporal features from the sequences of environmental parameters. It is composed of three key components: the Patch-Global Aggregator, Gated Recurrent Unit (GRU), and the Cross-Attention mechanism. The Patch-Global Aggregator integrates local information across individual patches, the GRU further captures temporal dependencies within the sequence, and the cross-attention mechanism enables deep interaction between target variables and auxiliary variables.
First, considering that the contributions of local and global information at each time step t may vary, the Patch-Global Aggregator applies dynamic weighting to the k + 1 vectors p j in X e n i (where j = 1, 2, …, k and G denotes the global vector). The detailed computation is defined in Equations (10)–(12):
e t j = tanh W e h t 1 ; p j ,
α t j = s o f t m a x e t j = e x p e t j i = 1 n   e x p e t i ,
p ~ t j = α t k p t j ,
p j denotes a vector in X e n i (where j = 1, 2,…, k and G represents the global vector), and p j is the weighted vector at time t. W e is a learnable weight matrix, and h t 1 is the hidden state at time t − 1 from the Gated Recurrent Unit (GRU) following the Patch-Global Aggregator.
The GRU, an improved variant of the Recurrent Neural Network (RNN), is well-suited for temporal feature extraction due to its recurrent architecture. GRU is a computationally efficient type of RNN [29], whose core idea is to use gating mechanisms to selectively retain or update historical information, thereby capturing dynamic patterns in time series data. It consists primarily of two gates: the update gate z t , which determines the extent to which historical and new information are integrated into the current hidden state, and the reset gate r t , which controls how much of the past hidden state is retained when computing the candidate hidden state. The GRU structure is illustrated in Figure 7.
In the Figure 7, p ~ t j   represents the vector at time t after weighting by the Patch-Global Aggregator. z t denotes the update gate, r t denotes the reset gate, h t 1 is the hidden state at time t − 1, h t is the hidden state at time t, and h ~ t is the candidate hidden state. The definitions of the update and reset gates, as well as the hidden state update rules in GRU, are given in Equations (13)–(16):
z t = σ W z h t 1 ; p ~ t j ,
r t = σ W r h t 1 ; p ~ t j ,
h ˜ t = t a n h W [ r t h t 1 ; p ~ t j ] ,
h t = ( 1 z t ) h t 1 + z t h ˜ t ,
σ and tanh are activation functions, and W z , W r , and W are learnable parameter matrices.
The combination of the Patch-Global Aggregator and GRU preserves local temporal features within each patch while enhancing the model’s ability to capture global temporal dependencies across patches. This significantly enhances the model’s ability to temporally model rabbit house environmental parameters.
To achieve feature decoupling between environmental and auxiliary parameters, a cross-attention mechanism is introduced. Specifically, the temporally encoded environmental parameter sequence serves as the query, while the channel-encoded auxiliary parameter sequence functions as the key and value in the attention computation. This mechanism enables the model to extract predictive and relevant information from the auxiliary sequence. The cross-attention process is illustrated in Figure 8.
The features fused through the cross-attention module are subsequently normalized to unify feature scales and accelerate training convergence. These normalized features are then passed through a feedforward neural network for nonlinear transformation.

2.4.3. Prediction Layer

The prediction layer employs a target-specific modeling strategy, comprising three parallel single-layer fully connected neural networks. Each network is independently responsible for predicting one of the following target variables: temperature, humidity, or CO2 concentration. The number of neurons in each network equals the prediction horizon. The input to each network is formed by concatenating multiple encoded feature patches corresponding to the respective environmental parameter, which are then used to generate multi-step forecasts for that parameter.

2.5. Model Performance Evaluation Metrics

The model performance was evaluated using three widely adopted metrics: Mean Absolute Error (MAE), Root Mean Squared Error (RMSE), and the Coefficient of Determination (R2). MAE provides an absolute measure of prediction error, while RMSE emphasizes larger deviations by penalizing squared errors more heavily. R2 quantifies the goodness of fit between predicted and observed values, with values closer to 1 indicating better predictive accuracy. The specific calculation formulas are given in Equations (17)–(19):
MAE = 1 n j = 1 n y j y j ,
RMSE = 1 n j = 1 n y j y j 2 ,
R 2 = j = 1 n   y j y 2 j = 1 n   y j y 2 ,
n denotes the number of predicted values, y j and y j represent the predicted and actual values, respectively, and ȳ denotes the mean of the actual values.

2.6. Model Test Platform

The hardware and software environments used for model training and testing are summarized in Table 4.
The hardware and software environments employed for model training and testing are presented in Table 5.

3. Results

To systematically and comprehensively evaluate the performance of PatchCrossFormer-RHP in multi-parameter and multi-step prediction tasks for rabbit house environments, this study conducted analyses on the impact of input and output sequence lengths, performance evaluation experiments, and ablation studies.
The experiments were conducted using a rabbit house environmental dataset collected in Fujian Province, which contained a total of 7548 samples. The dataset was chronologically divided into training, validation, and test sets in a ratio of 6:1:3, corresponding to 4529, 755, and 2264 samples, respectively. The training set was used for model parameter learning, the validation set for hyperparameter tuning and overfitting prevention, and the test set for final performance evaluation. Each sample included both indoor environmental parameters (air temperature, relative humidity, CO2 concentration, and wind speed) and outdoor parameters (air temperature and relative humidity). Within a multivariate prediction framework, the model was designed to forecast three key indicators: indoor air temperature, relative humidity, and CO2 concentration. Wind speed and outdoor environmental variables were incorporated as auxiliary inputs, while the prediction targets were restricted to the indoor parameters of temperature, humidity, and CO2 concentration.

3.1. Analysis of the Impact of Input and Output Sequence Lengths on Prediction Performance

The lengths of input and output sequences are critical parameters of the model. The input sequence represents the historical environmental data of the rabbit houses received by the model, and its length determines the range of historical information that the model can perceive. The output sequence length corresponds to the forecasting horizon, with different horizons serving different application scenarios and response requirements.
To evaluate the effects of varying input and output sequence lengths on model performance, a total of 21 experiments were conducted. Specifically, the input sequence length was set to seven values: 6, 12, 24, 48, 72, 96, and 144. For each input length, the output sequence length was configured to three values: 6, 12, and 24.
Figure 9 presents the prediction results under different combinations of input and output sequence lengths, where curves of different colors represent different output lengths.
Figure 9 demonstrates that, with a constant input sequence length, increasing the output sequence length results in higher RMSE and MAE values and lower R2 values. This trend indicates that model performance declines as the forecasting horizon extends, reflecting increased complexity and uncertainty. When the output sequence length is fixed, increasing the input sequence length generally causes RMSE and MAE to decrease initially, then stabilize or slightly increase. Extending the input sequence length within an optimal range enables the model to capture essential historical information. However, excessively long input sequences may introduce redundant data and noise, which can negatively affect model performance.
Experimental results indicate that, in multi-parameter joint prediction for rabbit houses, prediction targets differ in their reliance on historical data. Selecting a unified input length based solely on average optimal performance may not meet practical production needs. In this context, the relative importance of each indicator was considered. Temperature and humidity are directly involved in environmental regulation, making their prediction accuracy essential for maintaining stable conditions. While CO2 concentration remains important, it is not the primary parameter for direct control. Consequently, input length selection prioritized temperature and humidity prediction performance. An input length of 48 is recommended for an output sequence length of 6, and 72 for output sequence lengths of 12 or 24.

3.2. Performance Evaluation Experiments

To assess the predictive performance of the proposed model in practical applications, comparative experiments were conducted in accordance with the actual requirements of the rabbit house environmental regulation. Considering that a forecasting horizon of 2 h (i.e., output sequence length of 12) is sufficient for daily control needs, all subsequent experiments were performed with the output length fixed at 12.
RNN, GRU, and LSTM were selected as baseline models for comparison. These recurrent architectures have demonstrated strong nonlinear modeling and temporal memory capabilities, and are widely applied in environmental monitoring and intelligent agricultural control [30,31]. Specifically, RNN, GRU, and LSTM were implemented with a three-layer recurrent structure, 256 hidden units, and the tanh activation function.
The experiments were conducted using the Fujian dataset for both training and testing. To ensure fairness, PatchCrossFormer-RHP and the comparative models were configured with identical input and output sequence lengths, as well as the same optimizer (Adam), loss function (mean squared error, MSE), learning rate (0.001), batch size (128), and training epochs (100). The experimental results are reported in Table 6.
Table 6 reports the comparative performance of different models in multivariate forecasting tasks for temperature, humidity, and CO2 concentration. Overall, PatchCrossFormer-RHP consistently achieved the best performance across all three environmental parameters. Compared with the “best baseline” (the strongest among the comparative models), the temperature prediction RMSE decreased by 39.1% (0.476 → 0.290), MAE decreased by 40.5% (0.370 → 0.220), and R2 improved from 0.905 to 0.963. For humidity prediction, RMSE decreased by 15.4% (1.836 → 1.554), MAE decreased by 17.4% (1.273 → 1.052), and R2 improved from 0.923 to 0.956. For CO2 concentration prediction, RMSE decreased by 1.7% (39.506 → 38.837), MAE decreased by 14.9% (29.706 → 25.269), and R2 reached 0.838, matching GRU. These results verify the effectiveness of the proposed model in multivariate time-series modeling and cross-variable feature extraction.
Both GRU and LSTM consistently outperformed RNN, highlighting the importance of gated structures in modeling both long- and short-term dependencies, as well as in handling non-stationary disturbances. LSTM exhibited better performance than GRU in humidity prediction, while GRU surpassed LSTM in CO2 concentration prediction. This indicates that LSTM is more effective at capturing long-term memory in stable, gradually varying processes, whereas GRU, with fewer parameters, offers stronger robustness to noise.

3.3. Ablation Study

To quantify the contributions of key modules in PatchCrossFormer-RHP to prediction performance, a series of ablation experiments were conducted. Under the condition that all other structures remained unchanged, each core module of PatchCrossFormer-RHP was removed in turn, and the model was trained and tested on the Fujian dataset. The experimental results are summarized in Table 7.
As shown in Table 7, removing any key module led to a degradation in prediction performance, confirming that patch encoding, the Patch-Global Aggregator, and the cross-attention module all play essential roles in PatchCrossFormer-RHP. When the patch encoding module was removed, the RMSE of temperature, humidity, and CO2 concentration increased by approximately 122%, 63%, and 29%, respectively. Meanwhile, the MAE rose by more than 60%, and the R2 decreased by over 10%. This suggests that capturing local patterns makes a significant contribution to all variables and forms a critical foundation for enhancing predictive capability.
When the Patch-Global Aggregator was removed, the RMSE and MAE for temperature and humidity approximately doubled, whereas the decline in R2 was less than 2%. This suggests that the module makes a minimal contribution to trend capturing but plays a significant role in reducing absolute prediction errors. By aggregating local and global temporal information, it effectively suppresses numerical bias and enhances prediction accuracy.
In comparison, removing the cross-attention module caused relatively smaller performance degradation: the RMSE of temperature increased by 26%, while that of humidity and CO2 concentration rose by 15% and 5%, respectively. Although its effect on individual metrics was limited, the cross-attention mechanism plays a crucial role in facilitating feature interaction and information alignment between environmental and auxiliary parameters, thereby enabling the explicit modeling of temporal dependencies among different variables.
In summary, the three key modules each emphasize different aspects of performance and, when combined, jointly ensure the optimal predictive capability of PatchCrossFormer-RHP.

4. Discussion

As shown in Section 2.3, significant differences were observed in the environmental parameters of rabbit houses in Gansu, Henan, and Fujian. These differences mainly arose from regional variations in climate conditions, housing structures, stocking densities, management practices, and environmental control systems. To evaluate the generalization ability of PatchCrossFormer-RHP, particularly its adaptability to rabbit houses in different regions, cross-region cross-validation experiments were conducted. The model parameters were first randomly initialized, denoted as PatchCrossFormer-RHP (Init). Under the configurations described in Table 4 and Table 5, PatchCrossFormer-RHP (Init) was then trained separately on the Gansu dataset, the Henan dataset, and a combined dataset of both regions, yielding three pretrained models: PatchCrossFormer-RHP (GS), PatchCrossFormer-RHP (HN), and PatchCrossFormer-RHP (GS + HN). These four models served as the comparative baselines for subsequent analysis.
The Fujian dataset was divided into training, validation, and test sets with a ratio of 6:1:3. Based on this, the training set was further partitioned into six incremental subsets, as illustrated in Figure 10.
The four models were first evaluated directly on the Fujian test set to establish baseline performance without training. Subsequently, each model was trained on the six training subsets, with the validation set used for hyperparameter tuning and overfitting prevention during training. After training, the models were evaluated on the unified test set to quantify the impact of training data volume on predictive performance under cross-regional deployment. The experimental results are presented in Figure 11 and Table 7.
When trained on subset 1, all four models demonstrated a significant improvement in predictive performance compared to direct testing on the target dataset without training. Among them, the single-region pretrained models, PatchCrossFormer-RHP (GS) and PatchCrossFormer-RHP (HN), achieved larger and comparable gains, rapidly approaching their respective optimal performance levels. As the training subset size increased, the performance of all four models continued to improve, though at a slower pace. Notably, PatchCrossFormer-RHP (GS + HN) reached near-optimal performance after training with subset 4, requiring less data than the non-pretrained baseline PatchCrossFormer-RHP (Init). These findings suggest that pre-trained models can achieve satisfactory performance in cross-regional deployment with a relatively small amount of training data, and that single-region pre-trained models generally perform better.
The results obtained after training with subset 6 are reported in Table 8.
As shown in Table 8, all three pretrained models outperformed the randomly initialized PatchCrossFormer-RHP (Init) across all evaluation metrics, demonstrating that pretraining improves model performance in the target domain and validating the effectiveness of transfer learning. A comparison of PatchCrossFormer-RHP (GS), PatchCrossFormer-RHP (HN), and PatchCrossFormer-RHP (GS + HN) further reveals that the joint pretraining model (GS + HN) performed worse on all metrics than the single-source pretrained models. This indicates that single-source pretraining is generally superior to joint pretraining in cross-regional tasks. A possible explanation is that the data distributions of Gansu and Henan differ substantially; joint pretraining may cause the model to learn contradictory or overly specific features, thereby weakening its generalization ability.
In summary, pretraining enhances the cross-regional performance of PatchCrossFormer-RHP. In particular, single-source pretrained models achieve the best results, requiring only a small amount of target-domain data during fine-tuning to reach satisfactory performance. This demonstrates the strong adaptability of PatchCrossFormer-RHP across regions, highlighting that an appropriate pre-training strategy can effectively improve both predictive accuracy and transferability in cross-regional scenarios.

5. Conclusions

This study proposed a novel PatchCrossFormer-RHP model for predicting temperature, relative humidity, and CO2 concentration in rabbit houses, and conducted extensive experiments on Fujian datasets, with pretraining on data from Henan and Gansu to verify cross-regional transferability. Based on systematic analysis, the following conclusions were drawn:
  • PatchCrossFormer-RHP achieved the highest overall accuracy across all environmental parameters, outperforming RNN, GRU, and LSTM. Relative to the strongest baseline, the temperature prediction RMSE and MAE decreased by 39.1% and 40.5%, respectively, while humidity and CO2 concentration predictions also exhibited accuracy improvements, with RMSE and MAE reduced by 15.4% and 17.4% for humidity and by 1.7% and 14.9% for CO2 concentration. Taken together, these improvements confirm the model’s superior multivariate forecasting capability. The higher accuracy in temperature prediction is of particular practical importance, as temperature is the primary variable governing ventilation control and thermal comfort regulation in rabbit houses.
  • The patch-encoding module contributes most to the model’s ability to capture temporal regularities, as reflected by the largest drop in R2 when it was removed. This suggests that patch-based feature decomposition is a key factor in ensuring the model’s high explanatory power and predictive reliability.
  • PatchCrossFormer-RHP demonstrates excellent transferability. When pretrained on datasets from Gansu and Henan, its performance rapidly reached optimal levels after fine-tuning with only 10% of the target region’s data, underscoring its strong potential for practical applications. This performance arises from its patch-based representation and cross-attention design, which together enhance feature alignment and domain adaptability, enabling reliable prediction under varying climatic conditions.
The PatchCrossFormer-RHP model offers both theoretical guidance and practical solutions for intelligent environmental regulation in rabbit houses. In future work, the proposed framework will be integrated into environmental control systems and validated through on-farm experiments. Technical personnel will be able to design control strategies that jointly consider current conditions and predicted trends. The forecasting results can serve as the core component of Model Predictive Control (MPC) for optimization over the prediction horizon, or as auxiliary information for refining threshold-based or fuzzy control rules. This integration enhances the precision and adaptability of environmental regulation, ultimately improving housing stability, animal welfare, and production efficiency. However, the current study is limited by the geographic range of its data sources. Additional validation in more diverse regions and climatic conditions is necessary to comprehensively evaluate generalization and transferability. Future research will expand multi-scenario datasets and pursue lightweight model deployment to improve practicality and application value.

Author Contributions

Conceptualization, R.J. and G.W.; methodology, G.W.; software, G.W. and H.C.; validation, R.J., Z.L. and G.W.; formal analysis, G.W.; investigation, R.J. and Z.L.; resources, R.J. and G.W.; data curation, H.C.; writing—original draft preparation, R.J. and G.W.; writing—review and editing, Z.W.; visualization, G.W.; supervision, R.J. All authors have read and agreed to the published version of the manuscript.

Funding

This research was funded by the earmarked fund for CARS (CARS-43-D-2).

Institutional Review Board Statement

Ethical review and approval were not required for this study, as no animals were handled, treated, or otherwise affected during the study. The research was limited to evaluating environmental conditions within poultry houses, focusing exclusively on measuring and analyzing variables such as temperature, humidity, air quality, and other related factors.

Informed Consent Statement

Written informed consent was obtained from the owners of the animals involved in the study. All owners were informed of the data collection procedures, and consent was obtained prior to sampling.

Data Availability Statement

The experimental data are original and not convenient for public disclosure. If there is a reasonable request, please contact the authors.

Acknowledgments

We would like to thank the rabbit farm for providing rabbits for the experiments, offering the experimental site, and facilitating the completion of data collection.

Conflicts of Interest

The authors declare no conflicts of interest.

References

  1. Wu, L.; Qin, Y. An Analysis of the Development of China’s Rabbit Industry in 2023 and Its Outlook for 2024. Chin. J. Anim. Sci. 2024, 60, 347–351. [Google Scholar] [CrossRef]
  2. Ma, X.; Li, J.; Lin, J.; Geng, S.; Ma, J.; Liu, Z.; Wu, Z. Thermal Environment of Two Enclosure Structures in Angora Rabbit Breeding Houses in Shengzhou and Analysis of Suitable Temperature for Angora Rabbits. Chin. J. Anim. Sci. 2024, 60, 255–263. [Google Scholar] [CrossRef]
  3. Sun, Y.; Wang, Y.; Sa, R.; Zhang, H. Effects of Carbon Dioxide on Poultry and Control Measures. Chin. J. Anim. Nutr. 2018, 30, 2918–2924. [Google Scholar] [CrossRef]
  4. Dong, W.; Zhang, J.; Bian, S.; Zhou, Y.; Du, J.; Yu, H.; Zhong, W.; Song, H.; Wang, X. Comparative Analysis of Environmental Factors in Fattening Houses under Two Ventilation Modes in a Large-Scale Pig Farm in Hangzhou. China Anim. Husb. Vet. Med. 2023, 50, 421–428. [Google Scholar] [CrossRef]
  5. Li, B. Research on Environmental Regulation Technologies in Modernized Poultry Houses. BeiFang MuYe 2016, 23, 23. [Google Scholar]
  6. Hu, X.; Shen, P.; Li, X.; Cui, W.; Li, B.; Feng, X.; Pang, C. Ventilation Parameters and Application Effects of Pregnant Pig Houses in Subtropical Regions during Winter. Acta Ecol. Anim. Domest. 2024, 45, 65–72. [Google Scholar] [CrossRef]
  7. Lian, J.; Li, H.; Sun, K.; Yin, R.; Chen, W. Research Progress on Automated Environmental Control Technologies in Poultry Houses. China Poult. 2013, 35, 41–44. [Google Scholar]
  8. Yang, Y.; Zeng, Y.; Feng, Z.; Liu, Z.; Li, B. Research Status on Environmental Control Technologies and Intelligent Equipment for Livestock and Poultry Production. Bull. Chin. Acad. Sci. 2019, 34, 163–173. [Google Scholar] [CrossRef]
  9. Li, B.; Wang, Y.; Zheng, W.; Tong, Q. Research progress in environmental control key technologies, facilities and equipment for laying hen production in China. Trans. CSAE 2020, 36, 212–221. [Google Scholar] [CrossRef]
  10. Xie, Q.; Ni, J.; Bao, J.; Su, Z. A Thermal Environmental Model for Indoor Air Temperature Prediction and Energy Consumption in Pig Building. Build. Environ. 2019, 161, 106238. [Google Scholar] [CrossRef]
  11. Liang, C.; Yin, H.; Li, B.; Wang, C. Hourly model for predicting year-round temperature and relative humidity of the environment in laying hen houses. Trans. CSAE 2021, 37, 229–235. [Google Scholar] [CrossRef]
  12. Xie, Q.; Ni, J.; Bao, J.; Liu, H. Simulation and verification of microclimate environment in closed swine house based on energy and mass balance. Trans. CSAE 2019, 35, 148–156. [Google Scholar] [CrossRef]
  13. Liu, S.; Xu, L.; Li, D.; Zeng, L. Dissolved oxygen prediction model of eriocheir sinensis culture based on least squares support vector regression optimized by ant colony algorithm. Trans. CSAE 2012, 28, 167–175. [Google Scholar] [CrossRef]
  14. Shi, P.; Kuang, L.; Yuan, Y.; Zhang, H.; Li, G. Dissolved oxygen prediction for water quality of aquaculture using improved ELM network. Trans. CSAE 2020, 36, 225–232. [Google Scholar] [CrossRef]
  15. Petrakis, T.; Kavga, A.; Thomopoulos, V.; Argiriou, A. Neural Network Model for Greenhouse Microclimate Predictions. Agriculture 2022, 12, 780. [Google Scholar] [CrossRef]
  16. Zeng, Z.; Luo, Y.; Yu, Q.; Cai, R.; Lv, E.; Xia, J. Temperature prediction of intensive pig house based on time series and multivariate models. J. South China Agric. Univ. 2021, 42, 111–118. [Google Scholar] [CrossRef]
  17. Xie, Q.; Ma, C.; Wang, S.; Bao, J.; Liu, H.; Yu, H. Optimal Prediction Model for Gas Concentrations of NH3 and CO2 Time-series in Pig House. Trans. Chin. Soc. Agric. Mach. 2023, 54, 381–391. [Google Scholar] [CrossRef]
  18. Ji, R.; Shi, S.; Zhao, Y.; Liu, Z.; Wu, Z. Multivariable Environmental Prediction Model of Rabbit House Based on LSTM-Seq2Seq. Trans. Chin. Soc. Agric. Mach. 2021, 52, 396–401. [Google Scholar] [CrossRef]
  19. Xie, Q.; Zheng, P.; Bao, J.; Su, Z. Thermal Environment Prediction and Validation Based on Deep Learning Algorithm in Closed Pig House. Trans. Chin. Soc. Agric. Mach. 2020, 51, 353–361. [Google Scholar] [CrossRef]
  20. Chen, C.; Liu, X.; Liu, C.; Chang, R. Optimization of Evaluation and Prediction Model of Environmental Comfort in Lactating Sow House. Trans. Chin. Soc. Agric. Mach. 2020, 51, 311–319. [Google Scholar] [CrossRef]
  21. Li, W.; Wu, H.; Zhu, N.; Jiang, Y.; Tan, J.; Guo, Y. Prediction of Dissolved Oxygen in a Fishery Pond Based on Gated Recurrent Unit (GRU). Inf. Process. Agric. 2021, 8, 185–193. [Google Scholar] [CrossRef]
  22. Lee, S.; Lee, I.; Yeo, U.; Kim, J.; Kim, R. Machine Learning Approach to Predict Air Temperature and Relative Humidity inside Mechanically and Naturally Ventilated Duck Houses: Application of Recurrent Neural Network. Agriculture 2022, 12, 318. [Google Scholar] [CrossRef]
  23. Liu, F.; Yang, D.; Zhang, Y.; Yang, C.; Yang, J. Research on Multi-Parameter Prediction of Rabbit Housing Environment Based on Transformer. Int. J. Data Wareh. Min. 2024, 20, 1–19. [Google Scholar] [CrossRef]
  24. Feng, D.; Zhou, B.; Hassan, S.; Xu, L.; Liu, T.; Cao, L.; Liu, S.; Guo, J. A Hybrid Model for Temperature Prediction in a Sheep House. Animals 2022, 12, 2806. [Google Scholar] [CrossRef] [PubMed]
  25. Yang, L.; Liu, C.; Guo, Y.; Deng, H.; Li, D.; Duan, Q. Prediction of Ammonia Concentration in Fattening Piggery Based on EMD-LSTM. Trans. Chin. Soc. Agric. Mach. 2019, 50, 353–360. [Google Scholar] [CrossRef]
  26. Ji, R.; Shi, S.; Liu, Z.; Wu, Z. Decomposition-Based Multi-Step Forecasting Model for the Environmental Variables of Rabbit Houses. Animals 2023, 13, 546. [Google Scholar] [CrossRef] [PubMed]
  27. Ji, R.; Li, B.; Chen, Z.; Wu, Z. Regulation Model of Rabbit House Environment Based on Fuzzy Reasoning. Trans. Chin. Soc. Agric. Mach 2019, 50, 361–365. [Google Scholar] [CrossRef]
  28. Yang, F.; Guo, Z.; Xie, X.; Yi, J.; Lei, M. Research Progress on Nutritional Regulation of Heat Stress in Rabbits. China Herbiv. Sci. 2011, 31, 68–71. [Google Scholar] [CrossRef]
  29. Cho, K.; Merrienboer, B.; Gulcehre, C.; Bahdanau, D.; Bougares, F.; Schwenk, H.; Bengio, Y. Learning Phrase Representations Using RNN Encoder-Decoder for Statistical Machine Translation. arXiv 2014, arXiv:1406.1078. [Google Scholar]
  30. Elman, J. Finding Structure in Time. Cogn. Sci. 1990, 14, 179–211. [Google Scholar] [CrossRef]
  31. Hochreiter, S.; Schmidhuber, J. Long Short-Term Memory. Neural Comput. 1997, 9, 1735–1780. [Google Scholar] [CrossRef] [PubMed]
Figure 1. Actual exterior and interior views of the rabbit houses. (a) Exterior view of the rabbit house in Nanping, Fujian; (b) Interior view of the rabbit house in Nanping, Fujian; (c) Exterior view of the rabbit house in Qingyang, Gansu; (d) Interior view of the rabbit house in Qingyang, Gansu; (e) Exterior view of the rabbit house in Jiyuan, Henan; (f) Interior view of the rabbit house in Jiyuan, Henan.
Figure 1. Actual exterior and interior views of the rabbit houses. (a) Exterior view of the rabbit house in Nanping, Fujian; (b) Interior view of the rabbit house in Nanping, Fujian; (c) Exterior view of the rabbit house in Qingyang, Gansu; (d) Interior view of the rabbit house in Qingyang, Gansu; (e) Exterior view of the rabbit house in Jiyuan, Henan; (f) Interior view of the rabbit house in Jiyuan, Henan.
Animals 15 03192 g001
Figure 2. Schematic Diagram of Indoor Sensor Deployment. The sensors are divided into three groups, each consisting of a temperature and humidity sensor, a CO2 concentration sensor, and a wind speed sensor. Three sets of sensors were arranged laterally within each rabbit house: Group ① was positioned near the wet curtain side, Group ② at the center, and Group ③ near the fan side. The outdoor sensor was installed on a shaded section of the exterior wall.
Figure 2. Schematic Diagram of Indoor Sensor Deployment. The sensors are divided into three groups, each consisting of a temperature and humidity sensor, a CO2 concentration sensor, and a wind speed sensor. Three sets of sensors were arranged laterally within each rabbit house: Group ① was positioned near the wet curtain side, Group ② at the center, and Group ③ near the fan side. The outdoor sensor was installed on a shaded section of the exterior wall.
Animals 15 03192 g002
Figure 3. Seven-day mean variation curves of indoor temperature, humidity, and CO2 concentration in the three regions. (a) Temperature; (b) Humidity; (c) CO2 concentration.
Figure 3. Seven-day mean variation curves of indoor temperature, humidity, and CO2 concentration in the three regions. (a) Temperature; (b) Humidity; (c) CO2 concentration.
Animals 15 03192 g003
Figure 4. Correlation heatmaps of environmental parameters in rabbit houses. (a) Fujian; (b) Gansu; (c) Henan. Tin: indoor temperature; RHin: indoor humidity; CO2: indoor CO2 concentration; WS: indoor wind speed; Tout: outdoor temperature; RHout: outdoor humidity.
Figure 4. Correlation heatmaps of environmental parameters in rabbit houses. (a) Fujian; (b) Gansu; (c) Henan. Tin: indoor temperature; RHin: indoor humidity; CO2: indoor CO2 concentration; WS: indoor wind speed; Tout: outdoor temperature; RHout: outdoor humidity.
Animals 15 03192 g004
Figure 5. Architecture of PatchCrossFormer-RHP. The model includes an embedding layer, an encoder layer, and a prediction layer to output the predicted sequences of indoor temperature, humidity, and CO2 concentration. Tin, RHin, CO2, WS, Tout, and RHout denote indoor temperature, indoor humidity, indoor CO2 concentration, indoor wind speed, outdoor temperature, and outdoor humidity, respectively.
Figure 5. Architecture of PatchCrossFormer-RHP. The model includes an embedding layer, an encoder layer, and a prediction layer to output the predicted sequences of indoor temperature, humidity, and CO2 concentration. Tin, RHin, CO2, WS, Tout, and RHout denote indoor temperature, indoor humidity, indoor CO2 concentration, indoor wind speed, outdoor temperature, and outdoor humidity, respectively.
Animals 15 03192 g005
Figure 6. Temporal encoding strategy for environmental parameter sequences. The original sequence is divided into three segments (①–③), each representing a temporal patch. These patches are individually encoded as p 1 , p 2 and p 3 , while the original sequence is encoded as p G .
Figure 6. Temporal encoding strategy for environmental parameter sequences. The original sequence is divided into three segments (①–③), each representing a temporal patch. These patches are individually encoded as p 1 , p 2 and p 3 , while the original sequence is encoded as p G .
Animals 15 03192 g006
Figure 7. Structure of the GRU.
Figure 7. Structure of the GRU.
Animals 15 03192 g007
Figure 8. Illustration of the Cross-Attention Mechanism. Key and value are derived from encoded auxiliary parameters—indoor wind speed, outdoor temperature, and outdoor humidity.
Figure 8. Illustration of the Cross-Attention Mechanism. Key and value are derived from encoded auxiliary parameters—indoor wind speed, outdoor temperature, and outdoor humidity.
Animals 15 03192 g008
Figure 9. Prediction results under different combinations of input and output sequence lengths. (ac) Temperature prediction results, showing the variation of RMSE, MAE, and R2, respectively; (df) Humidity prediction results, showing the variation of RMSE, MAE, and R2, respectively; (gi) CO2 concentration prediction results, showing the variation of RMSE, MAE, and R2, respectively.
Figure 9. Prediction results under different combinations of input and output sequence lengths. (ac) Temperature prediction results, showing the variation of RMSE, MAE, and R2, respectively; (df) Humidity prediction results, showing the variation of RMSE, MAE, and R2, respectively; (gi) CO2 concentration prediction results, showing the variation of RMSE, MAE, and R2, respectively.
Animals 15 03192 g009
Figure 10. Schematic illustration of dataset partitioning. The percentage values denote the proportion relative to the total number of samples.
Figure 10. Schematic illustration of dataset partitioning. The percentage values denote the proportion relative to the total number of samples.
Animals 15 03192 g010
Figure 11. Model performance with varying proportions of the Fujian training dataset. (ac) Temperature prediction results, showing the variation of RMSE, MAE, and R2, respectively; (df) Humidity prediction results, showing the variation of RMSE, MAE, and R2, respectively; (gi) CO2 concentration prediction results, showing the variation of RMSE, MAE, and R2, respectively. The horizontal axis indicates the index of training subsets, where 0 denotes direct testing without training and 1–6 correspond to six incremental subsets containing 10–60% of the Fujian dataset (in steps of 10%).
Figure 11. Model performance with varying proportions of the Fujian training dataset. (ac) Temperature prediction results, showing the variation of RMSE, MAE, and R2, respectively; (df) Humidity prediction results, showing the variation of RMSE, MAE, and R2, respectively; (gi) CO2 concentration prediction results, showing the variation of RMSE, MAE, and R2, respectively. The horizontal axis indicates the index of training subsets, where 0 denotes direct testing without training and 1–6 correspond to six incremental subsets containing 10–60% of the Fujian dataset (in steps of 10%).
Animals 15 03192 g011aAnimals 15 03192 g011b
Table 1. Characteristics of the rabbit houses.
Table 1. Characteristics of the rabbit houses.
Farm LocationGeographical RegionDimensions (m) *Enclosure Structure
Qingyang, GansuInland, Northwest China43 × 13 × 3Color steel panel
Jiyuan, HenanInland, Central China28 × 12 × 4 Brick wall
Nanping, FujianSoutheastern coastal China27 × 6 × 6Brick wall
* Dimensions are expressed as Length × Width × Height (in meters).
Table 2. Specifications of sensors used in the rabbit houses.
Table 2. Specifications of sensors used in the rabbit houses.
Sensor TypeModelMeasurement
Range
AccuracyQuantity
Indoor Temperature and Humidity SensorRS-WS-N01-2D−40 °C to 80 °C
0% to 99% RH
±0.2 °C (at 25 °C)
±2% RH (at 60%, 25 °C)
3
Indoor CO2 SensorRS-CO2-N010~5000 ppm±(50 ppm + 3% F.S.)
(at 25 °C)
3
Indoor Ultrasonic AnemometerRS-CFSFX-N01-20~40 m/s±(0.5 m/s ± 2% F.S.)
(at 60% RH, 25 °C)
3
Outdoor Temperature and Humidity SensorRS-N01-BYH−40 °C to 120 °C
0% to 99% RH
±0.5 °C (at 25 °C)
±3% RH (at 60%, 25 °C)
1
Table 3. Seven-Day Average Statistics of Outdoor Temperature and Humidity in Three Regions.
Table 3. Seven-Day Average Statistics of Outdoor Temperature and Humidity in Three Regions.
RegionTemperature (°C)Humidity (%)
MaximumMinimumDiurnal
Range
MaximumMinimumDiurnal
Range
Nanping, Fujian30.1523.516.6498.0974.2523.83
Qingyang, Gansu23.1515.737.4295.0359.9335.10
Jiyuan, Henan29.9720.459.5197.1567.2629.89
Table 4. Hardware and software environments for model training and testing.
Table 4. Hardware and software environments for model training and testing.
Computational EnvironmentDetails
Operating systemWindows 10
Programming languagePython 3.7.12
Deep learning frameworkPyTorch 1.13.1
CPUIntel(R) Core(TM) i7-7700K CPU
GPUNvidia RTX 1080 GPU
RAM32 GB
Table 5. Training hyperparameters of the models.
Table 5. Training hyperparameters of the models.
Training HyperparametersValue
Optimization algorithmAdam
Batch size128
Epochs100
Initial learning rate0.001
Feature dimension256
Encoder layers3
Table 6. Comparison of Different Models for Indoor Temperature, Humidity, and CO2 Concentration Prediction at 2-Hour Forecast Horizon.
Table 6. Comparison of Different Models for Indoor Temperature, Humidity, and CO2 Concentration Prediction at 2-Hour Forecast Horizon.
ModelIndoor TemperatureIndoor HumidityCO2 Concentration
RMSE
(°C)
MAE
(°C)
R2RMSE
(%)
MAE
(%)
R2RMSE
(ppm)
MAE
(ppm)
R2
PatchCrossFormer-RHP0.2900.2200.9631.5541.0520.95638.83725.2690.838
RNN0.7830.6410.7442.8952.1650.81050.90539.8390.731
GRU0.4760.3740.9051.9961.3740.90939.50629.7060.838
LSTM0.4770.3700.9041.8361.2730.92342.04332.0970.816
Table 7. Results of ablation experiments on PatchCrossFormer-RHP.
Table 7. Results of ablation experiments on PatchCrossFormer-RHP.
Key ModulesIndoor TemperatureIndoor HumidityCO2 Concentration
Patch
Encoding
Patch-Global
Aggregator
Cross
Attention
RMSE
(°C)
MAE
(°C)
R2RMSE
(%)
MAE
(%)
R2RMSE
(ppm)
MAE
(ppm)
R2
× *0.6430.5160.8272.5341.9670.85450.21540.5870.738
√ *×0.6190.4510.9593.4732.3830.94247.61630.1870.764
×0.3650.2700.9441.7801.2050.92845.77130.0210.782
0.2900.2200.9631.5541.0520.95638.83725.2690.838
* √ denotes inclusion of the module, and × denotes its removal.
Table 8. Prediction performance of models trained with the full training dataset.
Table 8. Prediction performance of models trained with the full training dataset.
Environmental
Parameter
Evaluation
Metric
PatchCrossFormer
-RHP (Init)
PatchCrossFormer
-RHP (GS)
PatchCrossFormer
-RHP (HN)
PatchCrossFormer
-RHP (GS + HN)
Indoor
Temperature
RMSE (°C)0.2900.2760.2730.275
MAE (°C)0.2200.2030.1990.207
R20.9630.9660.9670.966
Indoor
Humidity
RMSE (%)1.5541.4311.4471.463
MAE (%)1.0520.9720.9881.005
R20.9560.9620.9620.961
CO2 ConcentrationRMSE (ppm)38.83738.23437.57638.230
MAE (ppm)25.26924.34324.24824.741
R20.8380.8430.8480.843
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Ji, R.; Wu, G.; Chang, H.; Liu, Z.; Wu, Z. A Patch and Attention Mechanism-Based Model for Multi-Parameter Prediction of Rabbit House Environmental Parameters. Animals 2025, 15, 3192. https://doi.org/10.3390/ani15213192

AMA Style

Ji R, Wu G, Chang H, Liu Z, Wu Z. A Patch and Attention Mechanism-Based Model for Multi-Parameter Prediction of Rabbit House Environmental Parameters. Animals. 2025; 15(21):3192. https://doi.org/10.3390/ani15213192

Chicago/Turabian Style

Ji, Ronghua, Guoxin Wu, Hongrui Chang, Zhongying Liu, and Zhonghong Wu. 2025. "A Patch and Attention Mechanism-Based Model for Multi-Parameter Prediction of Rabbit House Environmental Parameters" Animals 15, no. 21: 3192. https://doi.org/10.3390/ani15213192

APA Style

Ji, R., Wu, G., Chang, H., Liu, Z., & Wu, Z. (2025). A Patch and Attention Mechanism-Based Model for Multi-Parameter Prediction of Rabbit House Environmental Parameters. Animals, 15(21), 3192. https://doi.org/10.3390/ani15213192

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop