Abstract This paper combines the stepwise regression algorithm as well as the decision tree algorithm to design a decision tree stepwise regression algorithm model of the impact of the big Civics program on students’ mental health. This paper focuses on the use of a stepwise regression algorithm to eliminate the independent variables that do not have a significant impact on the dependent variable, and through the decision tree, ID3 method to test all the features, in-depth exploration of the degree of influence of the large courses of ideology and politics on students’ mental health. In order to be able to more deeply solve the degree of influence of the large course of thought and politics on students’ mental health, a oneway linear regression analysis is carried out on the basis of the relevant analysis data of students’ mental health. The results show that the histogram of the independent variable of the large course of ideology and the dependent variable of the total mean score is distributed in a normal curve, with a mean of 2.82E-16, a standard deviation of 0.999, and a correlation coefficient squared of 0.057, which indicates that the large course of ideology has a predictive effect on the mental health of students and that the students’ anorexia mental health is influenced by the large course of ideology by 0.057. This study shows that the large course of ideology is able to promote the physical and mental health development of students and contribute to the mental health of the students. This study shows that the large ideology and politics program can promote the healthy development of student’s physical and mental health, provide a direction for mental health education to become an effective carrier of “moral education”, and also provide a breakthrough point for the reform and innovation of students’ mental health education.