An Adaptive Metric Machine for Pattern Classification