A Patch and Attention Mechanism-Based Model for Multi-Parameter Prediction of Rabbit House Environmental Parameters
Simple Summary
Abstract
1. Introduction
2. Materials and Methods
2.1. Data Collection
2.2. Data Preprocessing
2.3. Data Analysis
2.4. Predictive Model Construction
2.4.1. Embedding Layer
2.4.2. Encoder
2.4.3. Prediction Layer
2.5. Model Performance Evaluation Metrics
2.6. Model Test Platform
3. Results
3.1. Analysis of the Impact of Input and Output Sequence Lengths on Prediction Performance
3.2. Performance Evaluation Experiments
3.3. Ablation Study
4. Discussion
5. Conclusions
- 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.
 
Author Contributions
Funding
Institutional Review Board Statement
Informed Consent Statement
Data Availability Statement
Acknowledgments
Conflicts of Interest
References
- 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]
 - 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]
 - 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]
 - 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]
 - Li, B. Research on Environmental Regulation Technologies in Modernized Poultry Houses. BeiFang MuYe 2016, 23, 23. [Google Scholar]
 - 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]
 - 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]
 - 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]
 - 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]
 - 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]
 - 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]
 - 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]
 - 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]
 - 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]
 - Petrakis, T.; Kavga, A.; Thomopoulos, V.; Argiriou, A. Neural Network Model for Greenhouse Microclimate Predictions. Agriculture 2022, 12, 780. [Google Scholar] [CrossRef]
 - 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]
 - 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]
 - 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]
 - 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]
 - 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]
 - 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]
 - 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]
 - 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]
 - 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]
 - 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]
 - 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]
 - 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]
 - 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]
 - 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]
 - Elman, J. Finding Structure in Time. Cogn. Sci. 1990, 14, 179–211. [Google Scholar] [CrossRef]
 - Hochreiter, S.; Schmidhuber, J. Long Short-Term Memory. Neural Comput. 1997, 9, 1735–1780. [Google Scholar] [CrossRef] [PubMed]
 












| Farm Location | Geographical Region | Dimensions (m) * | Enclosure Structure | 
|---|---|---|---|
| Qingyang, Gansu | Inland, Northwest China | 43 × 13 × 3 | Color steel panel | 
| Jiyuan, Henan | Inland, Central China | 28 × 12 × 4 | Brick wall | 
| Nanping, Fujian | Southeastern coastal China | 27 × 6 × 6 | Brick wall | 
| Sensor Type | Model | Measurement Range  | Accuracy | Quantity | 
|---|---|---|---|---|
| Indoor Temperature and Humidity Sensor | RS-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 Sensor | RS-CO2-N01 | 0~5000 ppm | ±(50 ppm + 3% F.S.) (at 25 °C)  | 3 | 
| Indoor Ultrasonic Anemometer | RS-CFSFX-N01-2 | 0~40 m/s | ±(0.5 m/s ± 2% F.S.) (at 60% RH, 25 °C)  | 3 | 
| Outdoor Temperature and Humidity Sensor | RS-N01-BYH | −40 °C to 120 °C 0% to 99% RH  | ±0.5 °C (at 25 °C) ±3% RH (at 60%, 25 °C)  | 1 | 
| Region | Temperature (°C) | Humidity (%) | ||||
|---|---|---|---|---|---|---|
| Maximum | Minimum | Diurnal Range  | Maximum | Minimum | Diurnal Range  | |
| Nanping, Fujian | 30.15 | 23.51 | 6.64 | 98.09 | 74.25 | 23.83 | 
| Qingyang, Gansu | 23.15 | 15.73 | 7.42 | 95.03 | 59.93 | 35.10 | 
| Jiyuan, Henan | 29.97 | 20.45 | 9.51 | 97.15 | 67.26 | 29.89 | 
| Computational Environment | Details | 
|---|---|
| Operating system | Windows 10 | 
| Programming language | Python 3.7.12 | 
| Deep learning framework | PyTorch 1.13.1 | 
| CPU | Intel(R) Core(TM) i7-7700K CPU | 
| GPU | Nvidia RTX 1080 GPU | 
| RAM | 32 GB | 
| Training Hyperparameters | Value | 
|---|---|
| Optimization algorithm | Adam | 
| Batch size | 128 | 
| Epochs | 100 | 
| Initial learning rate | 0.001 | 
| Feature dimension | 256 | 
| Encoder layers | 3 | 
| Model | Indoor Temperature | Indoor Humidity | CO2 Concentration | ||||||
|---|---|---|---|---|---|---|---|---|---|
| RMSE (°C)  | MAE (°C)  | R2 | RMSE (%)  | MAE (%)  | R2 | RMSE (ppm)  | MAE (ppm)  | R2 | |
| PatchCrossFormer-RHP | 0.290 | 0.220 | 0.963 | 1.554 | 1.052 | 0.956 | 38.837 | 25.269 | 0.838 | 
| RNN | 0.783 | 0.641 | 0.744 | 2.895 | 2.165 | 0.810 | 50.905 | 39.839 | 0.731 | 
| GRU | 0.476 | 0.374 | 0.905 | 1.996 | 1.374 | 0.909 | 39.506 | 29.706 | 0.838 | 
| LSTM | 0.477 | 0.370 | 0.904 | 1.836 | 1.273 | 0.923 | 42.043 | 32.097 | 0.816 | 
| Key Modules | Indoor Temperature | Indoor Humidity | CO2 Concentration | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Patch Encoding  | Patch-Global Aggregator  | Cross Attention  | RMSE (°C)  | MAE (°C)  | R2 | RMSE (%)  | MAE (%)  | R2 | RMSE (ppm)  | MAE (ppm)  | R2 | 
| × * | √ | √ | 0.643 | 0.516 | 0.827 | 2.534 | 1.967 | 0.854 | 50.215 | 40.587 | 0.738 | 
| √ * | × | √ | 0.619 | 0.451 | 0.959 | 3.473 | 2.383 | 0.942 | 47.616 | 30.187 | 0.764 | 
| √ | √ | × | 0.365 | 0.270 | 0.944 | 1.780 | 1.205 | 0.928 | 45.771 | 30.021 | 0.782 | 
| √ | √ | √ | 0.290 | 0.220 | 0.963 | 1.554 | 1.052 | 0.956 | 38.837 | 25.269 | 0.838 | 
| Environmental Parameter  | Evaluation Metric  | PatchCrossFormer -RHP (Init)  | PatchCrossFormer -RHP (GS)  | PatchCrossFormer -RHP (HN)  | PatchCrossFormer -RHP (GS + HN)  | 
|---|---|---|---|---|---|
| Indoor Temperature  | RMSE (°C) | 0.290 | 0.276 | 0.273 | 0.275 | 
| MAE (°C) | 0.220 | 0.203 | 0.199 | 0.207 | |
| R2 | 0.963 | 0.966 | 0.967 | 0.966 | |
| Indoor Humidity  | RMSE (%) | 1.554 | 1.431 | 1.447 | 1.463 | 
| MAE (%) | 1.052 | 0.972 | 0.988 | 1.005 | |
| R2 | 0.956 | 0.962 | 0.962 | 0.961 | |
| CO2 Concentration | RMSE (ppm) | 38.837 | 38.234 | 37.576 | 38.230 | 
| MAE (ppm) | 25.269 | 24.343 | 24.248 | 24.741 | |
| R2 | 0.838 | 0.843 | 0.848 | 0.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.  | 
© 2025 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
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
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 StyleJi, 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 StyleJi, 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
        