Using a `DistanceMetric` metric in `KNeighborsClassifier` raises. Our [documentation](https://scikit-learn.org/dev/modules/generated/sklearn.metrics.DistanceMetric.html#sklearn.metrics.DistanceMetric) of the class says: > DistanceMetric class > > This class provides a uniform interface to fast distance metric functions. The various metrics can be accessed via the get_metric class method and the metric string identifier (see below). From that documentation, I would expect the following code to work. I'm not sure if we want to fix the documentation or the code. ``` python from sklearn.neighbors import KNeighborsClassifier from sklearn.metrics import DistanceMetric as dm from sklearn.datasets import load_iris iris = load_iris() X = iris.data y = iris.target clf = KNeighborsClassifier(metric="euclidean") clf.fit(X,y) clf = KNeighborsClassifier(metric=dm.get_metric("euclidean")) clf.fit(X,y) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Users\Amanda\Miniconda3\envs\mlenv\lib\site-packages\sklearn\neighbors\_classification.py", line 198, in fit return self._fit(X, y) File "C:\Users\Amanda\Miniconda3\envs\mlenv\lib\site-packages\sklearn\neighbors\_base.py", line 437, in _fit self._check_algorithm_metric() File "C:\Users\Amanda\Miniconda3\envs\mlenv\lib\site-packages\sklearn\neighbors\_base.py", line 374, in _check_algorithm_metric raise ValueError( ValueError: Metric '<sklearn.metrics._dist_metrics.EuclideanDistance object at 0x0000018099BB9780>' not valid. Use sorted(sklearn.neighbors.VALID_METRICS['brute']) to get valid options. Metric can also be a callable function. ``` Pinging @jeremiedbb @lorentzenchr and maybe @ogrisel