Abstract:False data injection attack (FDIA) is a serious threat to the security and stable operation of smart grids. In this paper, a FDIA detection algorithm that combines unsupervised and supervised learning is proposed, solving the problems of scarce labeled data and extremely imbalanced normal and attack samples. Firstly, contrastive learning is introduced to capture the features of a small amount of attack data, and it generates new attack samples to achieve data augmentation. Then, various unsupervised detection algorithms are used to perform feature self-learning on a large number of unlabeled samples, addressing the problem of scarce labeled samples. Finally, the features extracted by the unsupervised algorithm are fused with the historical feature set, and a supervised XGBoost classifier is constructed to identify and output the detection results. The results on the IEEE 30-node system show that the proposed method can enhance the stability of the FDIA detection model under scarce labeled samples and imbalanced data, compared with other FDIA detection algorithms. The proposed method can improve recognition accuracy and reduce false alarm rate.