Accurate short-term electricity consumption forecasting is essential for optimizing energy management in Smart Campus Grids, particularly within a Smart City infrastructure. However, electricity consumption patterns exhibit variability due to fluctuating user behavior and external weather variables. To address these complexities, ensemble learning techniques have been explored. Stacking, in particular, leverages multiple base models through a meta-learner, offering an improved prediction accuracy for dynamic patterns.In this paper, we propose a stacking ensemble learning model to enhance short-term electricity consumption forecasting in a campus-scale Automated Metering infrastructure (AMI): a first step towards a fully integrated Smart Campus Grid. Our approach combines many base models including Extreme Gradient Boosting, Random Forest, Lasso Regression, and Support Vector Regression, with a Linear Regression model serving as the meta-learner. Our work uses on-site electricity consumption data collected from an AMI we already implemented consisting of 18 smart meters deployed at the National Institute of Posts and Telecommunications (INPT), a Moroccan engineering school with on-campus housing. Our ensemble model outperforms individual base models by an average of 8.7 %. This highlights the potential of advanced machine learning for accurate energy management in Smart Cities.
Forecasting power consumption is essential for intelligent power management in IoT-enabled smart environments, where heterogeneous behaviors appear from diverse building usages. University campuses are considered environments that share similarities with smart cities, making them suitable for power dynamics analysis. We build upon an IoT-based Advanced Metering Infrastructure (AMI) we deployed at our Engineering School’s Campus (INPT, Morocco), and an optimized XGBoost pipeline enhanced via Genetic Algorithms. Limited modeling granularity is addressed in heterogeneous consumption patterns. We propose and justify a cluster-aware approach partitioning data into K regimes such that . Each cluster is treated as a homogeneous behavioral profile and modeled using a GA-XGBoost model, enabling an intermediate granularity between global and meter-level learning. Experiments on real-world campus AMI data show that our proposed GA-XGBoost model consistently outperforms SVR and LSTM baselines across all clusters. In addition, cluster-specific models further improve performance compared to a single GA-XGBoost model trained without clustering, achieving a 48.42% improvement in MASE. Overall, beyond improving forecasting accuracy, cross-cluster generalization shows performance degradation and distributional shift when models are transferred across clusters, while residual diagnostics reveal differences in variance, temporal dependence, and non-Gaussianity.