One of the main concerns of power generation systems around the world is electricity theft. One of the goals of the Advanced Measurement Infrastructure (AMI) is to reduce the risk of electricity theft in the electric smart grids. However, the use of smart meters and the addition of a security layer to the measurement system paved the way for electricity theft. Nowadays, machine learning and data mining technologies are used to find abnormal patterns of consumption. The lack of a comprehensive dataset about abnormal consumption patterns, the issue of choosing effective features, the balance between consumer's normal and abnormal consumption patterns, and the choice of type and number of classifiers and how to combine them are the challenges of these technologies. Therefore, a detection system for electricity theft that is capable of effectively detecting theft attacks is needed. To this end, a framework including data preparation phases, feature selection, clustering, and combined modeling have been proposed to address the aforementioned challenges. In order to balance normal and abnormal data, 6 artificial attacks have been created. Moreover, with respect to the Chief element in the Raven optimization algorithm and its two-step search feature, this algorithm has been used in feature selection and clustering phases. Stacking as a two-step combined modeler has been used to strengthen the prediction of accuracy. In the second step of this modeler, the meta-Gaussian Processes algorithm is used due to the high accuracy of detection. The Irish Social Science Data Archive (ISSDA) dataset has been used to evaluate performance. The results show that the proposed method identifies dishonest customers with higher accuracy