The effective prediction of heating load in residential buildings is crucial for optimizing energy consumption and enhancing thermal comfort. This study investigates three prominent regression techniques Extra Tree Regression, Decision Tree Regression, and Support Vector Regression utilized for this purpose. To improve their predictive performance, a novel metaheuristic optimization algorithm, the Tyrannosaurus Rex Optimization Algorithm, is employed. The dataset used includes features such as Relative Compactness, Surface Area, Wall Area, Roof Area, Overall Height, Orientation, Glazing Area, and Glazing Area Distribution. Each machine learning model (Extra Tree Regression, Decision Tree Regression, Support Vector Regression) is trained on historical heating load data and optimized using the Tyrannosaurus Rex Optimization Algorithm to adjust internal parameters. Comparative analysis demonstrates that the proposed Extra Tree + Tyrannosaurus Rex Optimization Algorithm model achieves superior performance with an R-squared value of 0.987 and a low Root Mean Square Error of 1.167. By leveraging the strengths of different machine learning algorithms, this research presents a reliable approach for accurately predicting heating load in residential buildings. This method holds promise for improving energy efficiency, enhancing thermal comfort, and promoting sustainable building design.