A Method to Predict CO2 Mass Concentration in Sheep Barns Based on the RF-PSO-LSTM Model

Simple Summary With the change in meat sheep breeding from traditional farming to large-scale, intensified modern breeding practices, the environmental air quality in sheep barns has gradually started to receive more attention. CO2 concentration is an important environmental indicator in the ambient air of sheep sheds; when excess CO2 accumulates, it can lead to chronic hypoxia, lethargy, loss of appetite, weakness, and stress in sheep, which seriously endangers their healthy growth. Therefore, an accurate understanding of the trend of CO2 concentration changes in sheep housing and the precise regulation of their breeding environment are essential to ensure the welfare of sheep. Inspired by developments in deep learning technology in recent years, we propose a method to predict CO2 mass concentration in sheep barns based on the RF-PSO-LSTM model. The experimental results show that our proposed model has a root mean square error (RMSE) of 75.422 μg·m−3, a mean absolute error (MAE) of 51.839 μg·m−3, and a coefficient of determination (R2) of 0.992. The data predicted by the model are similar to the real data of a sheep barn; in fact, the prediction is better. Our proposed method can provide a reference for the prediction and regulation of ambient air quality in meat sheep barns. Abstract In large-scale meat sheep farming, high CO2 concentrations in sheep sheds can lead to stress and harm the healthy growth of meat sheep, so a timely and accurate understanding of the trend of CO2 concentration and early regulation are essential to ensure the environmental safety of sheep sheds and the welfare of meat sheep. In order to accurately understand and regulate CO2 concentrations in sheep barns, we propose a prediction method based on the RF-PSO-LSTM model. The approach we propose has four main parts. First, to address the problems of data packet loss, distortion, singular values, and differences in the magnitude of the ambient air quality data collected from sheep sheds, we performed data preprocessing using mean smoothing, linear interpolation, and data normalization. Second, to address the problems of many types of ambient air quality parameters in sheep barns and possible redundancy or overlapping information, we used a random forests algorithm (RF) to screen and rank the features affecting CO2 mass concentration and selected the top four features (light intensity, air relative humidity, air temperature, and PM2.5 mass concentration) as the input of the model to eliminate redundant information among the variables. Then, to address the problem of manually debugging the hyperparameters of the long short-term memory model (LSTM), which is time consuming and labor intensive, as well as potentially subjective, we used a particle swarm optimization (PSO) algorithm to obtain the optimal combination of parameters, avoiding the disadvantages of selecting hyperparameters based on subjective experience. Finally, we trained the LSTM model using the optimized parameters obtained by the PSO algorithm to obtain the proposed model in this paper. The experimental results show that our proposed model has a root mean square error (RMSE) of 75.422 μg·m−3, a mean absolute error (MAE) of 51.839 μg·m−3, and a coefficient of determination (R2) of 0.992. The model prediction curve is close to the real curve and has a good prediction effect, which can be useful for the accurate prediction and regulation of CO2 concentration in sheep barns in large-scale meat sheep farming.