Base class for Nearest neighbors classifier and regressor. Parameters ---------- k : int, default 5 The number of neighbors to take into account. If 0, all the training examples are used. distance_func : function, default euclidean distance
(self, k=5, distance_func=euclidean)
| 10 | |
| 11 | class KNNBase(BaseEstimator): |
| 12 | def __init__(self, k=5, distance_func=euclidean): |
| 13 | """Base class for Nearest neighbors classifier and regressor. |
| 14 | |
| 15 | Parameters |
| 16 | ---------- |
| 17 | k : int, default 5 |
| 18 | The number of neighbors to take into account. If 0, all the |
| 19 | training examples are used. |
| 20 | distance_func : function, default euclidean distance |
| 21 | A distance function taking two arguments. Any function from |
| 22 | scipy.spatial.distance will do. |
| 23 | """ |
| 24 | |
| 25 | self.k = None if k == 0 else k # l[:None] returns the whole list |
| 26 | self.distance_func = distance_func |
| 27 | |
| 28 | def aggregate(self, neighbors_targets): |
| 29 | raise NotImplementedError() |
nothing calls this directly
no outgoing calls
no test coverage detected