Using Artificial Neural Networks with GridSearchCV for Predicting Indoor Temperature in a Smart Home


  • Talal Alshammari Department of Information and Computer Science, College of Computer Science and Engineering, University of Ha’il, Saudi Arabia
Volume: 14 | Issue: 2 | Pages: 13437-13443 | April 2024 |


The acceleration of house technology via the use of mobile phones has made it easier to control houses, where occupants (especially older people) spend most of their time. The climate of Saudi Arabia, especially in the northern area, is too hot during summer and cold during winter. Control of the indoor environment in a smart home is a preferable choice that can reduce power consumption to operate heating, ventilation, and air-conditioning. Machine learning algorithms have been used to predict physical variables of indoor environment, such as temperature and humidity. The model can be trained, learn, and make predictions using historical data. Machine learning techniques can automate temperature monitoring and control. This paper proposes an algorithm that combines Artificial Neural Networks (ANNs) and GridSearchCV to predict physical variables in indoor environments in Saudi Arabia. GridSearchCV was utilized to tune the parameters of the machine learning algorithm. The assessment of the proposed algorithm involved its performance comparison to state-of-the-art machine learning algorithms. A real-world dataset was generated to estimate the performance of the considered algorithms. The room data were collected every 5 min for 31 days during July 2022. The dataset contains 6 columns and 8,910 records from 6 sensors (timestamps, light, temperature, humidity, pressure, and altitude). Random Forest (RF), Decision Tree (DT), and ANN methods were compared with the proposed algorithm. The RF had the highest R2 value of 0.84 and the lowest Mean Square Error (MSE) of 0.43. The DT achieved an R2 score of 0.78, while the ANN achieved R2 score of 0.61, MSE of 1.04, and Mean Absolute Error (MAE) of 0.75. The proposed algorithm achieved an R2 of 0.69, MSE of 0.87, and MAE of 0.67.


artificial neural networks, deep learning, machine learning algorithms, (Fast Furrier Transform) FFT


Download data is not yet available.


R. K. Nath and H. Thapliyal, "Wearable Health Monitoring System for Older Adults in a Smart Home Environment," in 2021 IEEE Computer Society Annual Symposium on VLSI (ISVLSI), Tampa, FL, USA, Jul. 2021, pp. 390–395.

B. N. Balmain, S. Sabapathy, M. Louis, and N. R. Morris, "Aging and Thermoregulatory Control: The Clinical Implications of Exercising under Heat Stress in Older Individuals," BioMed Research International, vol. 2018, 2018, Art. no. 8306154.

S. Vulova, F. Meier, D. Fenner, H. Nouri, and B. Kleinschmit, "Summer Nights in Berlin, Germany: Modeling Air Temperature Spatially With Remote Sensing, Crowdsourced Weather Data, and Machine Learning," IEEE Journal of Selected Topics in Applied Earth Observations and Remote Sensing, vol. 13, pp. 5074–5087, 2020.

Z. Li, P. Wang, J. Zhang, and S. Mu, "A strategy of improving indoor air temperature prediction in HVAC system based on multivariate transfer entropy," Building and Environment, vol. 219, Jul. 2022, Art. no. 109164.

W. Zhang, Y. Wu, and J. K. Calautit, "A review on occupancy prediction through machine learning for enhancing energy efficiency, air quality and thermal comfort in the built environment," Renewable and Sustainable Energy Reviews, vol. 167, Oct. 2022, Art. no. 112704.

M. Marzouk and M. Atef, "Assessment of Indoor Air Quality in Academic Buildings Using IoT and Deep Learning," Sustainability, vol. 14, no. 12, Jan. 2022, Art. no. 7015.

A. Fonseca, I. Abreu, M. J. Guerreiro, C. Abreu, R. Silva, and N. Barros, "Indoor Air Quality and Sustainability Management—Case Study in Three Portuguese Healthcare Units," Sustainability, vol. 11, no. 1, Jan. 2019, Art. no. 101.

S. H. Ryu and H. J. Moon, "Development of an occupancy prediction model using indoor environmental data based on machine learning techniques," Building and Environment, vol. 107, pp. 1–9, Oct. 2016.

C. Wang, D. Yan, H. Sun, and Y. Jiang, "A generalized probabilistic formula relating occupant behavior to environmental conditions," Building and Environment, vol. 95, pp. 53–62, Jan. 2016.

C. Li, H. Zhu, X. Lian, Y. Liu, X. Li, and Y. Feng, "Study of ‘time-lag’ of occupant behavior occurrences for establishing an occupant-centric building control system," Building and Environment, vol. 216, May 2022, Art. no. 109005.

S.-Y. Lin, S.-C. Chiu, and W.-Y. Chen, "Simple automatic supervisory control system for office building based on energy-saving decoupling indoor comfort control," Energy and Buildings, vol. 86, pp. 7–15, Jan. 2015.

S. Lee and D.-H. Choi, "Reinforcement Learning-Based Energy Management of Smart Home with Rooftop Solar Photovoltaic System, Energy Storage System, and Home Appliances," Sensors, vol. 19, no. 18, Jan. 2019, Art. no. 3937.

J. A. Weyn, D. R. Durran, and R. Caruana, "Can Machines Learn to Predict Weather? Using Deep Learning to Predict Gridded 500-hPa Geopotential Height From Historical Weather Data," Journal of Advances in Modeling Earth Systems, vol. 11, no. 8, pp. 2680–2693, 2019.

S. Serroni, M. Arnesano, L. Violini, and G. M. Revel, "An IoT measurement solution for continuous indoor environmental quality monitoring for buildings renovation," Acta IMEKO, vol. 10, no. 4, pp. 230–238, Dec. 2021.

T. Xing, K. Sun, and Q. Zhao, "MITP-Net: A deep-learning framework for short-term indoor temperature predictions in multi-zone buildings," Building and Environment, vol. 239, Jul. 2023, Art. no. 110388.

T. T. K. Tran, S. M. Bateni, S. J. Ki, and H. Vosoughifar, "A Review of Neural Networks for Air Temperature Forecasting," Water, vol. 13, no. 9, Jan. 2021, Art. no. 1294.

S. Francik and S. Kurpaska, "The Use of Artificial Neural Networks for Forecasting of Air Temperature inside a Heated Foil Tunnel," Sensors, vol. 20, no. 3, Jan. 2020, Art. no. 652.

S. R. Gopi and M. Karthikeyan, "Effectiveness of Crop Recommendation and Yield Prediction using Hybrid Moth Flame Optimization with Machine Learning," Engineering, Technology & Applied Science Research, vol. 13, no. 4, pp. 11360–11365, Aug. 2023.

A. H. Blasi, M. A. Abbadi, and R. Al-Huweimel, "Machine Learning Approach for an Automatic Irrigation System in Southern Jordan Valley," Engineering, Technology & Applied Science Research, vol. 11, no. 1, pp. 6609–6613, Feb. 2021.

P. V. D. de Souza, L. P. de Rezende, A. P. Duarte, and G. V. Miranda, "Maize Yield Prediction using Artificial Neural Networks based on a Trial Network Dataset," Engineering, Technology & Applied Science Research, vol. 13, no. 2, pp. 10338–10346, Apr. 2023.

E. Mocanu, P. H. Nguyen, M. Gibescu, and W. L. Kling, "Deep learning for estimating building energy consumption," Sustainable Energy, Grids and Networks, vol. 6, pp. 91–99, Jun. 2016.

J. Cifuentes, G. Marulanda, A. Bello, and J. Reneses, "Air Temperature Forecasting Using Machine Learning Techniques: A Review," Energies, vol. 13, no. 16, Jan. 2020, Art. no. 4215.

A. M. Gómez-Orellana, D. Guijo-Rubio, J. Pérez-Aracil, P. A. Gutiérrez, S. Salcedo-Sanz, and C. Hervás-Martínez, "One month in advance prediction of air temperature from Reanalysis data with eXplainable Artificial Intelligence techniques," Atmospheric Research, vol. 284, Mar. 2023, Art. no. 106608.

T. Alshammari, R. A. Ramadan, and A. Ahmad, "Temporal Variations Dataset for Indoor Environmental Parameters in Northern Saudi Arabia," Applied Sciences, vol. 13, no. 12, Jan. 2023, Art. no. 7326.

D. Chicco, M. J. Warrens, and G. Jurman, "The coefficient of determination R-squared is more informative than SMAPE, MAE, MAPE, MSE and RMSE in regression analysis evaluation," PeerJ. Computer Science, vol. 7, 2021, Art. no. e623.

M. Abdurohman, A. G. Putrada, and M. M. Deris, "A Robust Internet of Things-Based Aquarium Control System Using Decision Tree Regression Algorithm," IEEE Access, vol. 10, pp. 56937–56951, 2022.

"scikit-learn: machine learning in Python — scikit-learn 1.4.1 documentation." [Online]. Available:

S. Murugan, B. M. Kumar, and S. Amudha, "Classification and Prediction of Breast Cancer using Linear Regression, Decision Tree and Random Forest," in 2017 International Conference on Current Trends in Computer, Electrical, Electronics and Communication (CTCEEC), Mysore, India, Sep. 2017, pp. 763–766.

H. Salem, A. E. Kabeel, E. M. S. El-Said, and O. M. Elzeki, "Predictive modelling for solar power-driven hybrid desalination system using artificial neural network regression with Adam optimization," Desalination, vol. 522, Jan. 2022, Art. no. 115411.

T. Yan, S.-L. Shen, A. Zhou, and X. Chen, "Prediction of geological characteristics from shield operational parameters by integrating grid search and K-fold cross validation into stacking classification algorithm," Journal of Rock Mechanics and Geotechnical Engineering, vol. 14, no. 4, pp. 1292–1303, Aug. 2022.


How to Cite

T. Alshammari, “Using Artificial Neural Networks with GridSearchCV for Predicting Indoor Temperature in a Smart Home”, Eng. Technol. Appl. Sci. Res., vol. 14, no. 2, pp. 13437–13443, Apr. 2024.


Abstract Views: 51
PDF Downloads: 105

Metrics Information