Constructing a k-nearest neighbors regressor