Skip to content

Commit

Permalink
Warning for non-euclidean and non-manhattan metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
MechCoder committed Oct 21, 2014
1 parent 2daa028 commit bda6706
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions sklearn/neighbors/nearest_centroid.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#
# License: BSD 3 clause

import warnings
import numpy as np
from scipy import sparse as sp

Expand Down Expand Up @@ -126,6 +127,11 @@ def fit(self, X, y):
else:
self.centroids_[cur_class] = csc_median_axis_0(X[center_mask])
else:
if self.metric != 'euclidean':
warnings.warn("Averaging for metrics other than "
"euclidean and manhattan not supported. "
"The average is set to be the mean."
)
self.centroids_[cur_class] = X[center_mask].mean(axis=0)

if self.shrink_threshold:
Expand Down

0 comments on commit bda6706

Please sign in to comment.