Training Well-Generalizing Classifiers for Fairness Metrics and Other Data-Dependent Constraints