  Realistic finite temperature simulations of matter are a formidable challenge
for first principles methods. Long simulation times and large length scales are
required, demanding years of compute time. Here we present an on-the-fly
machine learning scheme that generates force fields automatically during
molecular dynamics simulations. This opens up the required time and length
scales, while retaining the distinctive chemical precision of first principles
methods and minimizing the need for human intervention. The method is widely
applicable to multi-element complex systems. We demonstrate its predictive
power on the entropy driven phase transitions of hybrid perovskites, which have
never been accurately described in simulations. Using machine learned
potentials, isothermal-isobaric simulations give direct insight into the
underlying microscopic mechanisms. Finally, we relate the phase transition
temperatures of different perovskites to the radii of the involved species, and
we determine the order of the transitions in Landau theory.
