  We present a machine-learning approach, based on the genetic algorithms (GA),
that can be used to reconstruct the inflationary potential directly from
cosmological data. We create a pipeline consisting of the GA, a primordial code
and a Boltzmann code used to calculate the theoretical predictions, and Cosmic
Microwave Background (CMB) data. As a proof of concept, we apply our
methodology to the Planck CMB data and explore the functional space of
single-field inflationary potentials in a non-parametric, yet analytical way.
We show that the algorithm easily improves upon the vanilla model of quadratic
inflation and proposes slow-roll potentials better suited to the data, while we
confirm the robustness of the Starobinsky inflation model (and other
small-field models). Moreover, using unbinned CMB data, we perform a first
concrete application of the GA by searching for oscillatory features in the
potential in an agnostic way, and find very significant improvements upon the
best featureless potentials, $\Delta \chi^2 < -20$. These encouraging
preliminary results motivate the search for resonant features in the primordial
power spectrum with a multimodal distribution of frequencies. We stress that
our pipeline is modular and can easily be extended to other CMB data sets and
inflationary scenarios, like multifield inflation or theories with higher-order
derivatives.
