Create a kNN classifier using the given training data and class labels
(
self,
train_data: np.ndarray[float],
train_target: np.ndarray[int],
class_labels: list[str],
)
| 22 | |
| 23 | class KNN: |
| 24 | def __init__( |
| 25 | self, |
| 26 | train_data: np.ndarray[float], |
| 27 | train_target: np.ndarray[int], |
| 28 | class_labels: list[str], |
| 29 | ) -> None: |
| 30 | """ |
| 31 | Create a kNN classifier using the given training data and class labels |
| 32 | """ |
| 33 | self.data = zip(train_data, train_target) |
| 34 | self.labels = class_labels |
| 35 | |
| 36 | @staticmethod |
| 37 | def _euclidean_distance(a: np.ndarray[float], b: np.ndarray[float]) -> float: |
nothing calls this directly
no outgoing calls
no test coverage detected