Metric Learning from Imbalanced Data