The notion of duality --the fact that a physical system enjoys surprisingly different descriptions-- is a key driver of modern theoretical physics. In this talk I will formulate the task of duality discovery in statistical physics as an optimisation problem that generalises the more standard one of fitting parameters in a Hamiltonian. I will show how a simple version of this problem can be solved to obtain an automated rediscovery of the celebrated Kramers-Wannier duality for the 2d Ising model. If time will permit, I will conclude with some preliminary results concerning more complicated models, and discuss how the framework could be applied to investigate unknown or poorly known dualities.