We use azomethane as an example to investigate its photoisomerization reaction inside the cavity. We present the non-adiabatic dynamics simulations outside the cavity for comparison. The results show that the machine learning model works well in the prediction of molecular dipoles, and derivatives. In addition, we observe that the reaction ratio of azomethane from the cis configuration to trans configuration can be well controlled by tuning the light-matter coupling strengths, the polarized directions of the electric field (see additional results in Supporting Information), and the cavity loss rates. We further provide mechanistic insight into how cavity can modify photochemical reactivities by carefully analyzing the population dynamics, cavity loss process, and the time evolution of the key nuclear degrees of freedom, the CNNC dihedral angle. We envision theoretical results may provide new inspiration for the experimental investigations polariton photochemistry in the molecule-cavity hybrid system.