The properties of the matter density field present in the initial conditions of a cosmological simulation have an impact on the features of the structures formed after running the simulation. Based on this fact, in this paper we use a random-forest classification algorithm to infer whether or not dark matter particles, traced back to the initial conditions, would end up in dark matter halos whose mass is above some threshold. This problem might be posed as a binary classification task, where the initial conditions of the matter density field are mapped to classification labels provided by a halo finder program. Our results show that random forests are useful tools to predict the output of cosmological simulations without running the full process. These techniques might be used in the future to save computational costs and to explore more efficiently the effect of different dark matter/dark energy candidates on the formation of cosmological structures.