|
21 | 21 | from ..base import ClassifierMixin
|
22 | 22 | from ..utils import check_array
|
23 | 23 |
|
| 24 | +import pdb |
| 25 | + |
24 | 26 |
|
25 | 27 | class KNeighborsClassifier(NeighborsBase, KNeighborsMixin,
|
26 | 28 | SupervisedIntegerMixin, ClassifierMixin):
|
@@ -391,7 +393,8 @@ def predict(self, X):
|
391 | 393 | for ind in neigh_ind[inliers]],
|
392 | 394 | dtype=object)
|
393 | 395 | 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) |
395 | 398 | y_pred_k[inliers] = mode
|
396 | 399 |
|
397 | 400 | if outliers and self.outlier_label != 0:
|
@@ -419,11 +422,14 @@ def predict(self, X):
|
419 | 422 |
|
420 | 423 | return y_pred
|
421 | 424 |
|
422 |
| - def _mode(self, pred_labels, weights, inliers): |
| 425 | + def _mode(self, pred_labels, weights, inliers, |
| 426 | + is_comming_from_sparse_call=None): |
423 | 427 | if weights is None:
|
424 | 428 | mode = np.array([stats.mode(pl)[0]
|
425 | 429 | for pl in pred_labels], dtype=np.int)
|
426 | 430 | else:
|
| 431 | + if is_comming_from_sparse_call: |
| 432 | + pdb.set_trace() |
427 | 433 | mode = np.array([weighted_mode(pl, w)[0]
|
428 | 434 | for (pl, w)
|
429 | 435 | in zip(pred_labels, weights[inliers])],
|
|
0 commit comments