With the continuous development of data science, the application of machine learning models in prediction and early warning systems is becoming increasingly widespread, and the construction field is no exception. This study mainly explores the application of Naive Bayes model and logistic regression model in the prediction and early warning system of construction accidents. Firstly, we collected and processed a large amount of historical data on construction accidents, including worker skill levels, working environment conditions, working hours, construction stages, and past safety records. Then, we trained and predicted these features using naive Bayesian models and logistic regression models. The experimental results show that naive Bayesian models have advantages in processing category features, while logistic regression models show high accuracy in processing continuous features. By combining the two models, our prediction and early warning system has shown high accuracy in predicting construction accidents and can provide sufficient warning time before accidents occur. This study provides new methods and perspectives for improving construction safety, and also provides valuable references for the application of these two models in other fields in the future.