-
Notifications
You must be signed in to change notification settings - Fork 389
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added _classes for knn classifiers #679
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for PR. Please check how classes are derived, because now we get some strange nesting between base classes.
supervised/algorithms/knn.py
Outdated
|
||
class KNeighborsAlgorithm(KNNFit, RegressorMixin): | ||
class KNeighborsAlgorithm(KNNFit, ClassifierMixin): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks strange, we derive from ClassifierMixin
in KNNFit as well ...
supervised/algorithms/knn.py
Outdated
@@ -73,7 +81,7 @@ def __init__(self, params): | |||
) | |||
|
|||
|
|||
class KNeighborsRegressorAlgorithm(KNNFit): | |||
class KNeighborsRegressorAlgorithm(KNNFit, RegressorMixin): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we derive from KNNFit
which derives from ClassifierMixin
and we also derive from RegressorMixin
. This looks strange ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i derived the KNeighborsAlgorithm
from both ClassifierMixin
and KNNFit
, where as the KNeighborsRegressorAlgorithm
from both RegressorMixin
and KNNFit
.
KNNFit
focuses on fitting the model, and KNeighborsAlgorithm
and KNeighborsRegressorAlgorithm
focus on the specific tasks of classification and regression, respectively.
tests/tests_algorithms/test_knn.py
Outdated
classes = None | ||
|
||
#debug statements | ||
print("np.unique(self.y):", np.unique(self.y)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we dont need debug statements, let use asserts
@pplonski is this working? |
Thank you @Hk669 for PR, good job 🥇 |
Thanks for the support @pplonski |
Added _classes attribute for k-Nearest Neighbors (KNN) Algorithm
Description:
This pull request addresses the issue #669 and implements the addition of the _classes attribute for the k-Nearest Neighbors algorithm.
Changes Made:
Modified the KNNFit class to include the _classes attribute, providing unique classes based on the fitted model.
Updated the KNeighborsAlgorithm and KNeighborsRegressorAlgorithm classes to inherit from KNNFit and ClassifierMixin and RegressorMixin, respectively.
Adjusted relevant unit tests to ensure the proper functioning of the _classes attribute.
Testing:
checklist: