Research on the Prediction of Greenhouse Temperature and Humidity Using an IPSO-LSTM Model
Abstract
1. Introduction
2. Mathematical Model and Evaluation Method
2.1. Particle Swarm Optimization (PSO)
2.2. Improved Particle Swarm Optimization (IPSO)
2.3. Long Short-Term Memory Model
2.4. Model Implementation Approach
- Data collection: Collected environmental data from inside the greenhouse, including temperature and humidity.
- Data preprocessing: Utilized modules such as pandas and NumPy in Python to handle missing values and filter out anomalies in the collected greenhouse environment data. Normalized the data after preprocessing.
- Sample data partitioning: Divided the data into training sets and testing sets.
- Parameter initialization: Initialized IPSO parameters and set the initial parameters of the LSTM model, including the number of input layers, hidden layer neurons, output layer neurons, iteration count, learning rate, and batch size.
- Optimization process: Defined the fitness function “f.” The IPSO algorithm compared the fitness value of each particle, updated the particles’ positions and velocities within a certain number of iterations to find the global optimal value, and updated the hyperparameters of the LSTM model.
- Model prediction: Incorporated the optimal hyperparameters into the IPSO-LSTM combined model for greenhouse environment prediction, compared and analyzed the predicted values with the actual values.
- Repeat predictions: Performed repeated predictions with the improved model and compared the predictive accuracy of each model.
2.5. Evaluation Metrics
- (1)
- Mae [31]:
- (2)
- Mape [32]:
- (3)
- RMSE [33]:
- (4)
- R2 [34]:
3. Results and Discussion
3.1. Data Collection and Preprocessing
3.1.1. Data Collection
3.1.2. Exception Value Handling
3.1.3. Data Standardization
3.2. Model Comparison
3.3. Prediction Results with Different Training Sample Volume
3.4. Implications for Greenhouse Management
4. Conclusions
Author Contributions
Funding
Institutional Review Board Statement
Informed Consent Statement
Data Availability Statement
Conflicts of Interest
References
- Ullah, I.; Fayaz, M.; Naveed, N.; Kim, D. ANN Based Learning to Kalman Filter Algorithm for Indoor Environment Prediction in Smart Greenhouse. IEEE Access 2020, 8, 159371–159388. [Google Scholar] [CrossRef] [Scilit]
- Lin, D.Y.; Wei, R.H.; Xu, L.H. An Integrated Yield Prediction Model for Greenhouse Tomato. Agronomy 2019, 9, 873. [Google Scholar] [CrossRef] [Scilit]
- Sahdev, R.K.; Kumar, M.; Dhingra, A.K. A comprehensive review of greenhouse shapes and its applications. Front. Energy 2019, 13, 427–438. [Google Scholar] [CrossRef] [Scilit]
- Moon, T.; Son, J.E. Knowledge transfer for adapting pre-trained deep neural models to predict different greenhouse environments based on a low quantity of data. Comput. Electron. Agric. 2021, 185, 106136. [Google Scholar] [CrossRef] [Scilit]
- Jung, D.-H.; Lee, T.S.; Kim, K.; Park, S.H. A Deep Learning Model to Predict Evapotranspiration and Relative Humidity for Moisture Control in Tomato Greenhouses. Agronomy 2022, 12, 2169. [Google Scholar] [CrossRef] [Scilit]
- Jia, W.; Wei, Z. Short Term Prediction Model of Environmental Parameters in Typical Solar Greenhouse Based on Deep Learning Neural Network. Appl. Sci. 2022, 12, 12529. [Google Scholar] [CrossRef] [Scilit]
- Arsenault, R.; Martel, J.-L.; Brunet, F.; Brissette, F.; Mai, J. Continuous streamflow prediction in ungauged basins: Long short-term memory neural networks clearly outperform traditional hydrological models. Hydrol. Earth Syst. Sci. 2023, 27, 139–157. [Google Scholar] [CrossRef] [Scilit]
- Chen, Y.; Shi, G.; Jiang, H.; Zheng, T. Research on the Prediction of Insertion Resistance of Wheel Loader Based on PSO-LSTM. Appl. Sci. 2023, 13, 1372. [Google Scholar] [CrossRef] [Scilit]
- Wang, J.; Xu, J.; Lu, Y.; Xie, T.; Peng, J.; Yang, F.; Ma, X. Prediction of molten pool temperature in laser solid forming based on PSO-LSTM. Front. Mater. 2023, 10, 1218222. [Google Scholar] [CrossRef] [Scilit]
- Jiao, X.; Song, Y.; Kong, Y.; Tang, X.L. Volatility forecasting for crude oil based on text information and deep learning PSO-LSTM model. J. Forecast. 2022, 41, 933–944. [Google Scholar] [CrossRef] [Scilit]
- Mu, G.; Liao, Z.; Li, J.; Qin, N.; Yang, Z. IPSO-LSTM hybrid model for predicting online public opinion trends in emergencies. PLoS ONE 2023, 18, e0292677. [Google Scholar] [CrossRef] [Scilit]
- Huang, Q.; Wang, X. A Forecasting Model of Wind Power Based on IPSO-LSTM and Classified Fusion. Energies 2022, 15, 5531. [Google Scholar] [CrossRef] [Scilit]
- Khatir, A.; Capozucca, R.; Khatir, S.; Magagnini, E.; Benaissa, B.; Le Thanh, C.; Wahab, M.A. A new hybrid PSO-YUKI for double cracks identification in CFRP cantilever beam. Compos. Struct. 2023, 311, 116803. [Google Scholar] [CrossRef] [Scilit]
- Khatir, A.; Capozucca, R.; Khatir, S.; Magagnini, E.; Cuong-Le, T. Enhancing Damage Detection Using Reptile Search Algorithm-Optimized Neural Network and Frequency Response Function. J. Vib. Eng. Technol. 2025, 13, 88. [Google Scholar] [CrossRef] [Scilit]
- Khatir, A.; Capozucca, R.; Khatir, S.; Magagnini, E. Vibration-based crack prediction on a beam model using hybrid butterfly optimization algorithm with artificial neural network. Front. Struct. Civ. Eng. 2022, 16, 976–989. [Google Scholar] [CrossRef] [Scilit]
- Escamilla-Garcia, A.; Soto-Zarazua, G.M.; Toledano-Ayala, M.; Rivas-Araiza, E.; Gastélum-Barrios, A. Applications of Artificial Neural Networks in Greenhouse Technology and Overview for Smart Agriculture Development. Appl. Sci. 2020, 10, 3835. [Google Scholar] [CrossRef] [Scilit]
- Liu, Y.; Li, D.; Wan, S.; Wang, F.; Dou, W.; Xu, X.; Li, S.; Ma, R.; Qi, L. A long short-term memory-based model for greenhouse climate prediction. Int. J. Intell. Syst. 2022, 37, 135–151. [Google Scholar] [CrossRef] [Scilit]
- Ullah, I.; Fayaz, M.; Aman, M.; Kim, D. Toward Autonomous Farming-A Novel Scheme Based on Learning to Prediction and Optimization for Smart Greenhouse Environment Control. IEEE Internet Things J. 2022, 9, 25300–25323. [Google Scholar] [CrossRef] [Scilit]
- Gao, M.; Wu, Q.; Li, J.; Wang, B.; Zhou, Z.; Liu, C.; Wang, D. Temperature prediction of solar greenhouse based on NARX regression neural network. Sci. Rep. 2023, 13, 1563. [Google Scholar] [CrossRef] [Scilit]
- Mohammadi, B.; Mehdizadeh, S.; Ahmadi, F.; Linh, N.T.T.; Pham, Q.B. Developing hybrid time series and artificial intelligence models for estimating air temperatures. Stoch. Environ. Res. Risk Assess. 2021, 35, 1189–1204. [Google Scholar] [CrossRef] [Scilit]
- Mohammadi, B. Modeling Various Drought Time Scales via a Merged Artificial Neural Network with a Firefly Algorithm. Hydrology 2023, 10, 58. [Google Scholar] [CrossRef] [Scilit]
- Tran-Ngoc, H.; He, L.; Reynders, E.; Khatir, S.; Le-Xuan, T.; De Roeck, G.; Bui-Tien, T.; Wahab, M.A. An efficient approach to model updating for a multispan railway bridge using orthogonal diagonalization combined with improved particle swarm optimization. J. Sound. Vib. 2020, 476, 115315. [Google Scholar] [CrossRef] [Scilit]
- Chen, X.Y.; Jiang, Z.H.; Tai, Q.L.; Shen, C.; Rao, Y.; Zhang, W. Construction of a photosynthetic rate prediction model for greenhouse strawberries with distributed regulation of light environment. Math. Biosci. Eng. 2022, 19, 12774–12791. [Google Scholar] [CrossRef] [Scilit]
- Wang, D.; Tan, D.; Liu, L. Particle swarm optimization algorithm: An overview. Soft Comput. 2018, 22, 387–408. [Google Scholar] [CrossRef] [Scilit]
- Yuan, P.; Lei, Z.; Zeng, Q.; Wu, Y.; Lu, Y.; Hu, C. Load forecasting of refrigerated display cabinet based on CEEMD-IPSO-LSTM combined model. Open Phys. 2021, 19, 360–374. [Google Scholar] [CrossRef] [Scilit]
- Duc, T.T.; Ngoc, T.V.; Jongho, K. Improving the Accuracy of Dam Inflow Predictions Using a Long Short-Term Memory Network Coupled with Wavelet Transform and Predictor Selection. Mathematics 2021, 9, 551. [Google Scholar] [CrossRef] [Scilit]
- Mendo, L. Estimation of a Probability with Guaranteed Normalized Mean Absolute Error. IEEE Commun. Lett. 2009, 13, 817–819. [Google Scholar] [CrossRef] [Scilit]
- Khair, U.; Fahmi, H.; Al Hakim, S.; Rahim, R. Forecasting Error Calculation with Mean Absolute Deviation and Mean Absolute Percentage Error. In Proceedings of the International Conference on Information and Communication Technology (IconICT), Medan, Indonesia, 15 July–25 August 2017. [Google Scholar]
- Soundiran, R.; Radhakrishnan, T.K.; Natarajan, S. Modeling of greenhouse agro-ecosystem using optimally designed bootstrapping artificial neural network. Neural Comput. Appl. 2019, 31, 7821–7836. [Google Scholar] [CrossRef] [Scilit]
- Chicco, D.; Warrens, M.J.; Jurman, G. The coefficient of determination R-squared is more informative than SMAPE, MAE, MAPE, MSE and RMSE in regression analysis evaluation. PeerJ Comput. Sci. 2021, 7, e623. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Qi, J.; Du, J.; Siniscalchi, S.M.; Ma, X.; Lee, C.-H. On Mean Absolute Error for Deep Neural Network Based Vector-to-Vector Regression. IEEE Signal Process. Lett. 2020, 27, 1485–1489. [Google Scholar] [CrossRef] [Scilit]
- Wen, X.; Jaxa-Rozen, M.; Trutnevyte, E. Accuracy indicators for evaluating retrospective performance of energy system models. Appl. Energy 2022, 325, 119906. [Google Scholar] [CrossRef] [Scilit]
- Karunasingha, D.S.K. Root mean square error or mean absolute error? Use their ratio as well. Inf. Sci. 2022, 585, 609–629. [Google Scholar] [CrossRef] [Scilit]
- Piepho, H.-P. An adjusted coefficient of determination (R2) for generalized linear mixed models in one go. Biom. J. 2023, 65, e2200290. [Google Scholar] [CrossRef] [Scilit]
- Kochhar, A.; Kumar, N. Wireless sensor networks for greenhouses: An end-to-end review. Comput. Electron. Agric. 2019, 163, 104877. [Google Scholar] [CrossRef] [Scilit]
- Singh, M.C.; Singh, J.P.; Singh, K.G. Development of a microclimate model for prediction of temperatures inside a naturally ventilated greenhouse under cucumber crop in soilless media. Comput. Electron. Agric. 2018, 154, 227–238. [Google Scholar] [CrossRef] [Scilit]
- Lee, J.; Im, S.; Jeong, J.-S.; Lee, T.S.; Park, S.H.; Shin, C.; Ju, H.; Kim, H.-J. Learning hidden relationship between environment and control variables for direct control of automated greenhouse using Transformer-based model. Comput. Electron. Agric. 2025, 235, 110335. [Google Scholar] [CrossRef] [Scilit]
- Shi, D.; Yuan, P.; Liang, L.; Gao, L.; Li, M.; Diao, M. Integration of deep learning and sparrow search algorithms to optimize greenhouse microclimate prediction for seedling environment suitability. Agronomy 2024, 14, 254. [Google Scholar] [CrossRef] [Scilit]
- Guo, Z.; Feng, L. Multi-step prediction of greenhouse temperature and humidity based on temporal position attention LSTM. Stoch. Environ. Res. Risk Assess. 2024, 38, 4907–4934. [Google Scholar] [CrossRef] [Scilit]













| Model | (Temperature) | (Humidity) | Advantages | Disadvantages |
|---|---|---|---|---|
| Standard LSTM | ~0.95 | ~0.89 | Strong long-term dependency capture | Manual tuning prone to local optima |
| PSO-LSTM | ~0.97 | ~0.93 | Automated tuning, better accuracy | Premature convergence, weak global search |
| SSA-LSTM | ~0.98 | ~0.95 | Fast convergence, high efficiency | High computational cost, poor noise robustness |
| IPSO-LSTM (Proposed) | 0.9969 | 0.9967 | Highest accuracy, balanced search | Relatively high computational demand |
| Parameter | IPSO | PSO |
|---|---|---|
| dimensional | 3 | 3 |
| learning rate | 0.001~0.01 | 0.001~0.01 |
| learning factor C1 and C2 | 1.5, 1.5 | 1.5, 1.5 |
| weight coefficient | 0.2~0.8 | 0.8 |
| random number r1 and r2 | 0.8, 0.3 | 0.8, 0.3 |
| population size | 50 | 50 |
| Hidden layer neuron range | 10~200 | 10~200 |
| Forecasting Model | Forecasting Parameter | Iteration Times | Batch Size | Artificial Neuron | Fully Connected Layer | Learning Rate |
|---|---|---|---|---|---|---|
| LSTM | temperature | 100 | 128 | 50 | 20 | 0.001 |
| humidity | ||||||
| PSO-LSTM | temperature | 94 | 152 | 63 | 35 | 0.004 |
| humidity | 67 | 114 | 31 | 23 | 0.006 | |
| IPSO-LSTM | temperature | 98 | 139 | 65 | 6 | 0.008 |
| humidity | 96 | 152 | 43 | 41 | 0.003 |
| Forecasting Model | Target | MAPE | RMSE | MAE | R2 |
|---|---|---|---|---|---|
| LSTM | Temperature | 0.0302 | 0.6659 | 0.5317 | 0.9795 |
| Humidity | 0.0356 | 0.2681 | 0.2096 | 0.9758 | |
| PSO-LSTM | Temperature | 0.0147 | 0.3117 | 0.2481 | 0.9955 |
| Humidity | 0.0266 | 0.0247 | 0.0194 | 0.9866 | |
| IPSO-LSTM | Temperature | 0.0118 | 0.2607 | 0.1973 | 0.9969 |
| Humidity | 0.0127 | 0.0183 | 0.0144 | 0.9967 |
| Forecasting Model | Target | MAPE | RMSE | MAE | R2 |
|---|---|---|---|---|---|
| LSTM | Temperature | 0.0094 | 0.3527 | 0.2708 | 0.9913 |
| Humidity | 0.0317 | 0.0276 | 0.0199 | 0.9640 | |
| PSO-LSTM | Temperature | 0.0075 | 0.3171 | 0.2217 | 0.9929 |
| Humidity | 0.0250 | 0.0218 | 0.0159 | 0.9776 | |
| IPSO-LSTM | Temperature | 0.0063 | 0.2649 | 0.1867 | 0.9951 |
| Humidity | 0.0233 | 0.0217 | 0.0150 | 0.9778 |
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. |
© 2026 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.
Share and Cite
Zhou, D.; Liu, A.; Lv, Y.; Yuan, P. Research on the Prediction of Greenhouse Temperature and Humidity Using an IPSO-LSTM Model. AgriEngineering 2026, 8, 351. https://doi.org/10.3390/agriengineering8090351
Zhou D, Liu A, Lv Y, Yuan P. Research on the Prediction of Greenhouse Temperature and Humidity Using an IPSO-LSTM Model. AgriEngineering. 2026; 8(9):351. https://doi.org/10.3390/agriengineering8090351
Chicago/Turabian StyleZhou, Dan, Aolong Liu, Yanli Lv, and Pei Yuan. 2026. "Research on the Prediction of Greenhouse Temperature and Humidity Using an IPSO-LSTM Model" AgriEngineering 8, no. 9: 351. https://doi.org/10.3390/agriengineering8090351
APA StyleZhou, D., Liu, A., Lv, Y., & Yuan, P. (2026). Research on the Prediction of Greenhouse Temperature and Humidity Using an IPSO-LSTM Model. AgriEngineering, 8(9), 351. https://doi.org/10.3390/agriengineering8090351
