Under the background of the rapid progress of machine learning (ML) and information technology, the traditional classroom model is gradually replaced by the self-media classroom. This thesis aims to solve the problems of understanding abstract content and limited teaching in practical teaching. Based on the ideological and political integration teaching of building architecture, the online classroom design principle reflects the classroom optimization and design principle of building architecture from the perspective of ML. The data advantage is utilized, and the classroom application model is established using the deep learning algorithm through information input. The scene of field survey and building construction is presented from the perspective of mechanization. The simulated results are displayed in the classroom through online teaching combined with ideological education and political teaching mode. The research shows that ML combined with online classroom design breaks through the book face-to-face teaching mode of the traditional classroom through the dynamic demonstration of actual construction, the virtual building structure, and the innovative design of building material entity. It stimulates students’ interest in architecture courses, improves the overall learning efficiency, and promotes the ideological and political integration of building architecture courses. Besides, it is conducive to cultivating comprehensive architectural talents in the new era.