Stochastic k-Neighborhood Selection for Supervised and Unsupervised Learning