Generative Local Metric Learning for Nearest Neighbor Classification