Credit business is a vital part of the bank's core business, which has an extremely important impact on the bank's income and development. In the operation of credit business, credit risk assessment is particularly crucial, and accurate risk assessment can minimize risks while maximizing the bank's returns. We propose a method to optimize credit risk assessment using machine learning techniques. In this work, we employ a random forest machine learning model to process and analyze large amounts of loan application data. By using correlation analysis, information enrichment, etc., the characteristics that have the most impact on credit risk assessment are screened. Subsequently, the model was constructed using a random forest algorithm. Random forests improve the generalization ability and accuracy of the model by building multiple decision trees and introducing randomness between these trees. In the experimental analysis part, we compare the performance of various models on the German credit dataset, and the results show that the deep learning model outperforms the traditional machine learning model in most indicators, verifying the effectiveness of our method.