  We train a machine learning algorithm to learn cosmological structure
formation from N-body simulations. The algorithm infers the relationship
between the initial conditions and the final dark matter haloes, without the
need to introduce approximate halo collapse models. We gain insights into the
physics driving halo formation by evaluating the predictive performance of the
algorithm when provided with different types of information about the local
environment around dark matter particles. The algorithm learns to predict
whether or not dark matter particles will end up in haloes of a given mass
range, based on spherical overdensities. We show that the resulting predictions
match those of spherical collapse approximations such as extended
Press-Schechter theory. Additional information on the shape of the local
gravitational potential is not able to improve halo collapse predictions; the
linear density field contains sufficient information for the algorithm to also
reproduce ellipsoidal collapse predictions based on the Sheth-Tormen model. We
investigate the algorithm's performance in terms of halo mass and radial
position and perform blind analyses on independent initial conditions
realisations to demonstrate the generality of our results.
