Topological invariants allow one to characterize Hamiltonians, predicting the existence of topologically protected in-gap modes. Those invariants can be computed by tracing the evolution of the occupied wave functions under twisted boundary conditions. However, those procedures do not allow one to calculate a topological invariant by evaluating the system locally, and thus require information about the wave functions in the whole system. Here we show that artificial neural networks can be trained to identify the topological order by evaluating a local projection of the density matrix. We demonstrate this for two different models, a one-dimensional topological superconductor and a two-dimensional quantum anomalous Hall state, both with spatially modulated parameters. Our neural network correctly identifies the different topological domains in real space, predicting the location of in-gap states. By combining a neural network with a calculation of the electronic states that uses the kernel polynomial method, we show that the local evaluation of the invariant can be carried out by evaluating a local quantity, in particular for systems without translational symmetry consisting of tens of thousands of atoms. Our results show that supervised learning is an efficient methodology to characterize the local topology of a system.