K-nearest neighbor discriminant analysis