Skip to content

Commit a03237d

Browse files
author
Joan Massich
committed
wip
1 parent c4a47e3 commit a03237d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

sklearn/neighbors/classification.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
from ..base import ClassifierMixin
2222
from ..utils import check_array
2323

24+
import pdb
25+
2426

2527
class KNeighborsClassifier(NeighborsBase, KNeighborsMixin,
2628
SupervisedIntegerMixin, ClassifierMixin):
@@ -391,7 +393,8 @@ def predict(self, X):
391393
for ind in neigh_ind[inliers]],
392394
dtype=object)
393395
y_pred_k = np.zeros(n_samples, dtype=np.int)
394-
mode = self._mode(pred_labels, weights, inliers)
396+
mode = self._mode(pred_labels, weights, inliers,
397+
is_comming_from_sparse_call=True)
395398
y_pred_k[inliers] = mode
396399

397400
if outliers and self.outlier_label != 0:
@@ -419,11 +422,14 @@ def predict(self, X):
419422

420423
return y_pred
421424

422-
def _mode(self, pred_labels, weights, inliers):
425+
def _mode(self, pred_labels, weights, inliers,
426+
is_comming_from_sparse_call=None):
423427
if weights is None:
424428
mode = np.array([stats.mode(pl)[0]
425429
for pl in pred_labels], dtype=np.int)
426430
else:
431+
if is_comming_from_sparse_call:
432+
pdb.set_trace()
427433
mode = np.array([weighted_mode(pl, w)[0]
428434
for (pl, w)
429435
in zip(pred_labels, weights[inliers])],

0 commit comments

Comments
 (0)