Refining Machine Learning Potentials through Thermodynamic Theory of Phase Transitions