K-nearest neighbors relies on the definition of a global metric. In contrast, discriminant adaptive nearest neighbor (DANN) computes a different metric at each query point based on a local linear discriminant analysis. In this paper, we propose a technique to automatically adjust the hyper-parameters in DANN by the optimization of two quality criteria. The first one measures the quality of discrimination, while the second one maximizes the local class homogeneity. We use a Bayesian formulation to prevent over-fitting.