The invention relates to a software defect prediction method based on few sample data learning, and belongs to the field of software engineering. The method comprises the following steps of S1, constructing an SDNN based on a twin network, i.e., a twin full connection network; S2, inputting positive sample data and negative sample data, performing few-sample learning through an SDNN network, and extracting high-level depth features of the samples on the data; S3, performing comparative learning and probability output on the high-level deep features extracted in the step S2 by adopting a metriclearning function, adjusting the proportion of positive and negative samples, and setting function learning parameters, so that the metric learning function more pays more attention to learning of defective data features; S4, obtaining a prediction result. Compared with the prior art, the method adopted by the invention has the advantages that a better prediction effect can be obtained on a limited, high-dimensional and unbalanced data set, and the performance is more stable under different unbalance rates; and a better prediction result can be obtained under the conditions of less data, lesstime and the like.