A Canonical Data Transformation for Achieving Inter- and Within-group Fairness