-
-
Notifications
You must be signed in to change notification settings - Fork 26.1k
API Removes the use of fit_ and partial_fit_ in Birch #19297
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
API Removes the use of fit_ and partial_fit_ in Birch #19297
Conversation
sklearn/cluster/_birch.py
Outdated
) | ||
@property | ||
def fit_(self): | ||
return self.__fit |
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.
Because _fit
is already taken.
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.
A double underscore in Python does "name mangling" which is not necessarily a thing Python developers are familiar with:
https://en.wikipedia.org/wiki/Name_mangling#Python
I don't think this is necessarily a problem for this code but maybe we should avoid them for the sake of not surprising people?
We could use _deprecad_fit_flag
instead for instance.
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.
Updated PR with a non-named mangled name.
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.
LGTM.
I guess we still need to document them in the mean time (being done in #18796).
sklearn/cluster/_birch.py
Outdated
self.__fit, self.__partial_fit = True, False | ||
return self._fit(X, partial=False) |
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.
Maybe add a comment "TODO remove in 1.2" so we don't forget (there's another occurence below).
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.
+1 for the general idea. We just need to agree on the point on name mangling raised here: #19297 (comment) and fix it if we judge that it's better to avoid name mangling in our code base.
This PR removes the use of
fit_
andpartial_fit_
inBirch
and update the implementation to not require it.CC @jeremiedbb @adrinjalali