Prediction of pair potential given a typical configuration of an interacting classical system is a difficult inverse problem. There exists no exact result that can predict the potential given the structural information. We demonstrate that using machine learning (ML) one can get a quick but accurate answer to the question: which pair potential lead to the given structure (represented by pair correlation function)? We use artificial neural network (NN) to address this question and show that this ML technique is capable of providing very accurate prediction of pair potential irrespective of whether the system is in a crystalline, liquid or gas phase. We show that the trained network works well for sample system configurations taken from both equilibrium and out of equilibrium simulations (active matter systems) when the later is mapped to an effective equilibrium system with a modified potential. We show that the ML prediction about the effective interaction for the active system is not only useful to make prediction about the MIPS (motility induced phase separation) phase but also identifies the transition towards this state.