To accurately and rapidly predict compound flooding in coastal cities, we developed a data and mechanism dual-driven model considering the impacts of rainfall, tide level, and river runoff. Taking the Meishe River Basin in Haikou City as a case study, we constructed a physically-driven and numerically-driven coupled dataset based on the personal computer storm water management model (PCSWMM). Subsequently, a rapid prediction model for the compound flooding distribution was proposed based on the Bayesian optimized gradient boosting decision tree (GBDT) algorithm. The simulation results of the 1D-2D coupled urban flooding model based on PCSWMM has an absolute simulation error of less than 0.04 m, presenting an accurate simulation of actual inundation. The correlation coefficient (R2) between the predicted values of the GBDT model and those of the PCSWMM model is close to 0.98, and the computational speed is increased by more than 261 times. This approach enables more accurate and quicker compound flooding predictions for coastal cities.