You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
NearestCentroid class throw a FutureWarning when using metric='cosine'.
Actually, the metric is use for two things:
inside .fit() for the computation of the centroids:
with euclidean: centroids are computed using the mean of features
with manhattan: centroids are computed using the median
ifself.metric=="manhattan":
# NumPy does not calculate median of sparse matrices.ifnotis_X_sparse:
self.centroids_[cur_class] =np.median(X[center_mask], axis=0)
else:
self.centroids_[cur_class] =csc_median_axis_0(X[center_mask])
else:
# TODO(1.5) remove warning when metric is only manhattan or euclideanifself.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)
inside .predict(): the metric is used for the pairwise distance
../sklearn/neighbors/_nearest_centroid.py:150: FutureWarning: Support for distance metrics other than euclidean and manhattan and for callables was deprecated in version 1.3 and will be removed in version 1.5.
warnings.warn(
../sklearn/neighbors/_nearest_centroid.py:201: UserWarning: Averaging for metrics other than euclidean and manhattan not supported. The average is set to be the mean.
Describe the bug
NearestCentroid class throw a FutureWarning when using
metric='cosine'
.Actually, the metric is use for two things:
.fit()
for the computation of the centroids:.predict()
: the metric is used for the pairwise distanceBut, what if I want to use centroids computed with the mean of features and using cosine (or other) metric to compute the pairwise distance ?
Steps/Code to Reproduce
Expected Results
No error is thrown.
Actual Results
Versions
The text was updated successfully, but these errors were encountered: