Diabetes mellitus is one of the major diseases in the world. The pathogenesis is complex and difficult to cure, and accurate prediction of the risk of diabetes can help improve the treatment rate. Machine learning, as an important branch of artificial intelligence, can discover potential relationships between data, to efficiently carry out disease prediction and risk assessment. In this paper, a logistic regression prediction model was constructed, and an authoritative dataset was used as the research object, including 8 medical characteristics as the variables for predicting diabetes. First, some data pretreatment steps were taken to eliminate any invalid or missing data, and then the model was trained the prediction test set was carried out, and finally, the five main evaluation indicators of the model were obtained. The results showed that the logistic regression model had an accuracy rate of 0.95, a precision rate of 0.85, a recall rate of 0.63, an F1 Score of 0.73, and an AUC Value of 0.96. The results show that the prediction model has good stability and accuracy, can effectively predict diabetes, and has certain potential clinical application value.