Ideological and political (IAP) education is the soul of socialist construction. As the main position for the cultivation of the “Four Haves” in the cause of socialist construction, colleges and universities shoulder an important educational mission. However, standard, scientific, systematic, and feasible evaluation index system is lacking in the teaching of IAP theory courses. Therefore, it is fervently required to use the modern science and technology for the establishment of a complete, objective, and feasible classroom teaching evaluation system, and the optimization of the evaluation process is also an important issue that needs to be resolved urgently. This paper combines teaching evaluation theory and machine learning methods, analyzes the rationality of evaluation indicators through the acquired evaluation data, and optimizes the evaluation system. By comparing the advantages and disadvantages of traditional machine learning classification algorithms, a classifier based on weighted naive Bayes is analyzed and designed for teaching evaluation, and the specific process of evaluation model construction is introduced. The experimental results show that the classification model based on the weighted naive Bayes algorithm is reasonable and feasible for teaching evaluation. Combined with the weighted Bayesian classification incremental learning principle, the performance of the classification model can be better than the traditional classification model.