In recent years,the incidence of highway accidents on freeways remains high.In the meantime,loop detectors are commonly equipped on freeways.Thus,it is necessary to dig the data of loop detectors in order to predict realtime risk of traffic accidents on freeways.Based on data of actual accidents and collected from detectors on four freeways called I5,I10,I405 and I15 in California,where the most accident numbers occurred in the year 2012,extracting data group of accidents and non-accidents based on an idea of case-control study.Study coverage of detector data is selected.Meanwhile,ADASYN algorithm is used to solve the problem of unbalanced data sets.Based on random forest,three basic traffic flow data within 10-40 min before accidents collected from four upstream detectors and two downstream detectors is used to compute locations of accidents.A real-time accident risk model on freeways is developed with the accuracy rate of accident prediction is 88.02 %.The top ten important variables are selected as important inducements of accidents.Then,the values of the important inducements are adjusted.The modified test set is applied to the random forest model for classification forecasting afterwards.The result shows that the numbers of accidents are reduced by 41.82%.Therefore,it can be found that the important inducements of accidents can be applied to the early warning of traffic accidents,thus reducing the incidence of them.