In this study, a novel technique to support smart city planning in estimating and controlling the heating load (HL) of buildings, was proposed, namely PSO-XGBoost. Accordingly, the extreme gradient boosting machine (XGBoost) was developed to estimate HL first; then, the particle swarm optimization (PSO) algorithm was applied to optimize the performance of the XGBoost model. The classical XGBoost model, support vector machine (SVM), random forest (RF), Gaussian process (GP), and classification and regression trees (CART) models were also investigated and developed to predict the HL of building systems, and compared with the proposed PSO-XGBoost model; 837 investigations of buildings were considered and analyzed with many influential factors, such as glazing area distribution (GAD), glazing area (GA), orientation (O), overall height (OH), roof area (RA), wall area (WA), surface area (SA), and relative compactness (RC). Mean absolute percentage error (MAPE), root-mean-squared error (RMSE), variance account for (VAF), mean absolute error (MAE), and determination coefficient (R2), were used as the statistical criteria for evaluating the performance of the above models. The color intensity, as well as the ranking method, were also used to compare and evaluate the models. The results showed that the proposed PSO-XGBoost model was the most robust technique for estimating the HL of building systems. The remaining models (i.e., XGBoost, SVM, RF, GP, and CART) yielded more mediocre performance through RMSE, MAE, R2, VAF, and MAPE metrics. Another finding of this study also indicated that OH, RA, WA, and SA were the most critical parameters for the accuracy of the proposed PSO-XGBoost model. They should be particularly interested in smart city planning as well as the optimization of smart cities.