On the ERM Principle With Networked Data