Abstract:A stable temperature and humidity environment is crucial for the health and production performance of pregnant sows. To address the inadequacy in adaptability of traditional prediction models under multi-factor coupling scenarios in gestation pig houses, an IBWO-Stacking prediction model was proposed based on improved beluga whale optimization (IBWO)and Stacking ensemble learning. The proposed method enhanced the optimization capability of the original beluga whale optimization (BWO)algorithm through three key improvements: Logistic chaotic mapping initialization, adaptive variable adjustment, and pattern search integration. These enhancements enabled effective hyperparameter optimization of base learners in the Stacking ensemble framework, the model predicted environmental temperature and humidity. Experimental results demonstrated that the IBWO-Stacking model achieved superior performance metrics: for humidity prediction, the mean absolute error (MAE), mean squared error (MSE), and root mean squared error (RMSE)were 1. 123 7% , 3. 243 4% 2 and 1. 800 9% respectively. For temperature prediction, these metrics reached 0. 210 4℃, 1. 216 5℃ 2 and 1. 102 9℃. Comparative analysis with the baseline BWO-stacking model showed significant improvements: the coefficient of determination (R2 )was increased by approximately 0. 55% for humidity and 1. 32% for temperature prediction. Concurrently, MAE was decreased by 7. 35% and 6. 36% , MSE was reduced by 17. 23% and 30. 92% , while RMSE declined by 9. 02% and 16. 9% for humidity and temperature predictions respectively. These results validated the enhanced predictive capability and robustness of the IBWO-Stacking model, providing decision-making support for intelligent environmental control in gestation pig houses, thereby mitigating the negative impacts of environmental stress on the reproductive performance of sows.