  Modeling ferroelectric materials from first principles is one of the
successes of density-functional theory, and the driver of much development
effort, requiring an accurate description of the electronic processes and the
thermodynamic equilibrium that drive the spontaneous symmetry breaking and the
emergence of macroscopic polarization. We demonstrate the development and
application of an integrated machine learning model that describes on the same
footing structural, energetic and functional properties of barium titanate
($\text{BaTiO}_3$), a prototypical ferroelectric. The model uses ab initio
calculations as reference and achieves accurate yet inexpensive predictions of
energy and polarization on time and length scales that are not accessible to
direct ab initio modeling. These predictions allow us to assess the microscopic
mechanism of the ferroelectric transition. The presence of an order-disorder
transition for the Ti off-centered states is the main driver of the
ferroelectric transition, even though the coupling between symmetry breaking
and cell distortions determines the presence of intermediate, partly-ordered
phases. Moreover, we thoroughly probe the static and dynamical behavior of
$\text{BaTiO}_3$ across its phase diagram, without the need to introduce a
coarse-grained description of the ferroelectric transition. Finally, we apply
the polarization model to calculate dielectric response properties of the
material in a fully ab initio manner, again reproducing the correct qualitative
experimental behaviour.
