Learning Causal Effects via Weighted Empirical Risk Minimization