How to effectively evaluate and identify the potential default risk of borrowers and calculate the default probability of borrowers before issuing loans is the basis and important link of credit risk management of modern financial institutions. This paper mainly studies the statistical analysis of the historical loan data of banks and other financial institutions with the help of the idea of unbalanced data classification, and uses the random forest algorithm to establish a loan default prediction model. Experimental results phenotype, neural network and random forest algorithm outperform decision tree and logistic regression classification algorithm in prediction performance. In addition, by using random forest algorithm to rank the importance of features, features that have a greater impact on the final default can be obtained, so as to make a more effective judgment of lending risks in the financial field.