Conversation
maybenotilya
left a comment
There was a problem hiding this comment.
Очень даже неплохо, но key-value лейблы и ломающиеся скейлеры это проблема
src/homeworks/homework2/KDTree.py
Outdated
| self.root: Node[T] = self._build_kdtree(points) | ||
|
|
||
| @staticmethod | ||
| def _select_axis(points: list[Point[T]]) -> int: |
There was a problem hiding this comment.
nit: Скорее ax, а не axis, ось то одна
src/homeworks/homework2/KDTree.py
Outdated
| node: Node[T] | None, | ||
| neighbors: list[tuple[float, Point[T]]], | ||
| ) -> list[tuple[float, Point[T]]]: | ||
| if node: |
There was a problem hiding this comment.
Довольно сложно читать такие огромные и страшные ветвения
|
|
||
| data = [Point(X[i]) for i in range(len(X))] | ||
| self.classifier = KDTree(data, leaf_size=self.leaf_size) | ||
| self.clss = {point: cls for point, cls in zip(data, y)} |
There was a problem hiding this comment.
Что мешает двум одинаковым точкам иметь разные лейблы?
|
|
||
| class Scaler(ABC): | ||
| @abstractmethod | ||
| def fit(self, data: NDArray[T]): |
There was a problem hiding this comment.
Немного странно что KNNClassifier работает с питоновскими листами, а скейлеры с нумпаем, но да ладно
src/homeworks/homework2/scalers.py
Outdated
| if self.min is None or self.max is None: | ||
| raise ValueError("Scaler has not been fitted yet.") | ||
|
|
||
| return (data - self.min) / (self.max - self.min) |
There was a problem hiding this comment.
Если max == min, то случится коллапс вселенной
src/homeworks/homework2/scalers.py
Outdated
| if self.max_abs is None: | ||
| raise ValueError("Scaler has not been fitted yet.") | ||
|
|
||
| return data / self.max_abs |
src/homeworks/homework2/scalers.py
Outdated
| if self.mean is None or self.std is None: | ||
| raise ValueError("Scaler has not been fitted yet.") | ||
|
|
||
| return (data - self.mean) / self.std |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
KNN with KD-Tree