A Comparative Study of Random Forest, K-Nearest Neighbors, and XGBoost Models for Weather-Aware Smart Office Building Automation - Erwin Yonata; Maya Anggun Beer; Ni Nyoman Putri Shopia; Emilia Loho; Gilang Raka Rayuda Dewa (Journal of Applied Computer Science and Technology, 2026)
The intelligent control of lighting and HVAC systems plays a critical role in reducing energy consumption in smart buildings. However, many existing automation systems rely on static scheduling strategies that fail to adapt to dynamic environmental conditions. Although machine learning has been widely applied to weather-based building automation, inconsistent feature selection, model configuration, and evaluation procedures limit the validity of comparative performance claims. This study aims to develop and evaluate a machine-learning-based weather classification framework for smart building automation. The proposed methodology follows a structured pipeline comprising data acquisition and preprocessing, model training and testing, parameter tuning, and performance evaluation. A publicly available Weather Type Classification dataset is used, consisting of numerical weather parameters, which are encoded prior to training. Feature selection is applied to identify the most influential predictors. Three machine learning models, Random Forest, K Nearest Neighbors, and XGBoost, are trained using an 80:20 stratified split, with hyperparameters optimized through grid search to ensure an optimized model. Model performance is evaluated using accuracy, precision, recall, F1 score, and a confusion matrix. Experimental results demonstrate that Random Forest achieves the highest accuracy of 97.50 percent, followed by XGBoost at 96.90 percent and K Nearest Neighbors at 95.73 percent, with balanced performance across all weather categories. The findings indicate that ensemble-based classifiers are well-suited for robust weather recognition. The classified weather outputs can be directly mapped to real-time control strategies for lighting and HVAC systems, enabling adaptive automation and improved energy efficiency in smart buildings.