The spatial distribution of galaxies in the Universe is not uniform but rather stands on a gigantic structure commonly called the “cosmic web”. In this pattern, dense nodes are linked together by elongated bridges of matter named filaments that are playing a key role in the formation and evolution of galaxies but also carries information about the cosmological model.In this presentation, we build several algorithms aiming at learning patterns in point-cloud datasets such as the galaxy distribution. We particularly focus on two kinds of patterns, with first clustered-type ones in which the data points are separated in the input space into multiple groups. We will show that the unsupervised clustering procedure performed with a Gaussian Mixture Model can be formulated in terms of a statistical physics optimization problem. This formulation enables the unsupervised extraction of much key information about the dataset itself, like the number of clusters, their size and how they are embedded in space, particularly interesting for high-dimensional input spaces where visualization is not possible.On the other hand, we study spatially continuous datasets assuming as standing on an underlying 1D structure that we aim to learn. To this end, we resort to a regularization of the Gaussian Mixture Model in which a spatial graph is used as a prior to approximate the underlying 1D structure. The overall graph is efficiently learnt by means of the Expectation-Maximisation algorithm with guaranteed convergence and comes together with the learning of the local width of the structure.