Skip to content

Commit

Permalink
DOC: Explain why the centroid of the manhattan metric is the median
Browse files Browse the repository at this point in the history
  • Loading branch information
MechCoder committed Oct 21, 2014
1 parent 9622e85 commit 3e7b816
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions sklearn/neighbors/nearest_centroid.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 32,11 @@ class NearestCentroid(BaseEstimator, ClassifierMixin):
feature array. If metric is a string or callable, it must be one of
the options allowed by metrics.pairwise.pairwise_distances for its
metric parameter.
The centroids for the samples corresponding to each class is the point
from which the sum of the distances (according to the metric) of all
samples that belong to that particular class are minimized.
If the "manhattan" metric is provided, this centroid is the median and
for all other metrics, the centroid is now set to be the mean.
shrink_threshold : float, optional (default = None)
Threshold for shrinking centroids to remove features.
Expand Down
2 changes: 1 addition & 1 deletion sklearn/utils/sparsefuncs.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 384,7 @@ def csc_row_median(X):
Returns
-------
median : ndarray, shape = (n_features,)
median : ndarray, shape (n_features,)
Median.
"""
Expand Down

0 comments on commit 3e7b816

Please sign in to comment.