In this study, we proposed a machine learning (ML) method to optimize the comprehensive performance of shape memory epoxy polymers (SMEPs) based on experimental data as samples. Firstly, a series of SMEPs specimens were prepared, and their properties were evaluated respectively by testing four indexes including the glass transition temperature (Tg), bending strength, strain fixation rate (Rf), and strain recovery rate (Rr). Subsequently, ML used these experimental data as samples for feature learning to investigate the influence of each component on these properties. The results indicated that methyltetrahydrophthalic anhydride was more favorable to Tg and bending strength than methylhexahydrophthalic anhydride (MHHPA) as a curing agent. However, a certain amount of MHHPA must be included in the system to guarantee a higher Rf and Rr. Moreover, the right amount of bisphenol A cyanate ester in the system improved the comprehensive properties of SMEPs, especially the shape memory effect. Finally, a SMEPs system with superior properties was acquired through the optimization of four indexes of Tg, bending strength, Rf and Rr. Therefore, this study shows that ML methods can also be used to investigate SMEPs that require more specific excellent performance.