Machine-learning enabled thermodynamic model for the design of new rare-earth compounds