The proton exchange membrane electrolytic cell (PEMEC) is a clean, pollution-free, and promising device for producing hydrogen from water electrolysis. This paper enhances the electrochemical performance of the PEMEC by developing a comprehensive three-dimensional two-phase non-isothermal heat and mass transfer cell model. An analysis was conducted to study the influence of various operating parameters on the temperature safety and efficiency of the cell. The performance of the latter was optimized by adopting the machine learning technology, which aimed at identifying optimal conditions for improved performance. The obtained results showed that, when the inlet water flow rate and membrane thickness were increased, the average temperature of the anode catalyst layer (A-CL) was decreased by 1.4 K and 2.31 K, respectively. This allowed to improve the safety of the electrolytic cell. However, it would reduce the hydrogen and oxygen mole fraction in the electrolyzer. On the contrary, enhancing the porosity or thickness of the anode gas diffusion layer can increase the average A-CL temperature and decrease the oxygen and hydrogen mole fraction. Therefore, the backpropagation neural network and non-dominated sorting genetic algorithm were used to predict and optimize the performance of the electrolyzer, in order to maximize its temperature safety, electrochemical reaction rate, and hydrogen evolution efficiency as much as possible. The results of this study provide a theoretical foundation for the selection of suitable cell models according to different conditions in engineering applications. It also has an application value in energy saving and sustainable development.