Aiming at the problems of result lag, mechanism difficulty and data heterogeneity existing in the effectiveness evaluation of ideological and political education in physical education courses, this paper constructs a prediction method combining machine learning and structural equation model. Twenty-eight physical education classes in three universities were selected as objects, and classroom behavior logs, exercise task performance, interaction records, reflective texts and scale data were collected. After cleaning, 796 effective samples, 12736 classroom behavior fragments were obtained, and 58 input features were extracted. The model used algorithms such as random forest and gradient boosting tree to identify key features, and then used structural equation model to describe the chain between teacher support, classroom engagement, responsibility and value identification. The results show that the R2, RMSE, MAE and MAPE of the proposed model on the test set are 0.914, 4.86, 3.71 and 5.94%, respectively. Compared with XGBoost, the R2 is increased by 0.049 and RMSE is decreased by 1.02. The research shows that the collaboration of machine learning and structural equation model can simultaneously improve the accuracy and explanatory power of the prediction of the ideological and political education effect of physical education courses.