Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Joan Massich committed Sep 14, 2017
1 parent c4a47e3 commit d467359
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions sklearn/neighbors/classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,8 @@ def predict(self, X):
for ind in neigh_ind[inliers]],
dtype=object)
y_pred_k = np.zeros(n_samples, dtype=np.int)
mode = self._mode(pred_labels, weights, inliers)
mode = self._mode(pred_labels, weights, inliers,
is_comming_from_sparse_call=True)
y_pred_k[inliers] = mode

if outliers and self.outlier_label != 0:
Expand Down Expand Up @@ -419,11 +420,13 @@ def predict(self, X):

return y_pred

def _mode(self, pred_labels, weights, inliers):
def _mode(self, pred_labels, weights, inliers, is_comming_from_sparse_call=None):
if weights is None:
mode = np.array([stats.mode(pl)[0]
for pl in pred_labels], dtype=np.int)
else:
if is_comming_from_sparse_call:
import pdb; pdb.set_trace()
mode = np.array([weighted_mode(pl, w)[0]
for (pl, w)
in zip(pred_labels, weights[inliers])],
Expand Down

0 comments on commit d467359

Please sign in to comment.