Artificial intelligence algorithms have been applied separately or integrally for prediction, classification or optimization of buildings energy consumption. However, there is a salient gap in the literature on the investigation of hybrid objective function development for energy optimization problems including qualitative and quantitative datasets in their constructs. To tackle with this challenge, this paper presents a hybrid objective function of machine learning algorithms in optimizing energy consumption of residential buildings through considering both continuous and discrete parameters of energy simultaneously. To do this, a comprehensive dataset including significant parameters of building envelop, building design layout and HVAC was established, Artificial Neural Network as a prediction and Decision Tree as a classification algorithm were employed via cross-training ensemble equation to create the hybrid function and the model was finally validated via the weighted average of the error decomposed for the performance. The developed model could effectively enhance the accuracy of the objective functions used in the building energy prediction and optimization problems. Furthermore, the results of this novel approach resolved the inclusion issue of both continuous and discrete parameters of energy in a unified objective function without threatening the integrity and consistency of the building energy datasets.