Learning a metric for class-conditional KNN