-
Notifications
You must be signed in to change notification settings - Fork 229
Fit constraints #19
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
Fit constraints #19
Conversation
Thanks for the PR! This is a tricky situation, partly due to the breaking change, but also because it brings up a good question about how people are expected to use this API. From my perspective, the main use-cases for metric learning are unsupervised/semisupervised learning. In those settings, you want to use all of the constraint information available, because it's likely pretty hard to get. The existing Even so, I agree that there should be a better / more compatible API for use in the greater scikit-learn ecosystem. The fact that most of the metric learners use different representations of their constraint information is a big pain, and the existing way of generating random constraints isn't useful for real world learning. In light of all this, I think it makes sense to:
Let me know what you think. |
Problem with
The only solution which comes to my mind for this scenario is to create What do you think? |
I thinking about this some more and even started implementing a skeleton. However I came to a conclusion that it adds up too much unnecessary complexity. Having two different methods (
I think it makes more sense than having separate classes for different constraints. |
I have reverted the classes to their original functionality (where |
I really like the new direction you've taken, thank you! I think this fits with the overall design of the package much better, and supports your use-case without too much friction. I have a number of small nitpicks, which I'll address inline, but I'm +1 for this idea. |
@@ -1,9 +1,14 @@ | |||
from __future__ import absolute_import | |||
|
|||
from .itml import ITML | |||
from .itml import ITML_Supervised |
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.
Here and below, I'd put these into one import statement:
from .itml import ITML, ITML_Supervised
I have fixed the problems you pointed out and marked the code with #TODO where you suggested bigger changes. Anything else to do here before merge? |
Looks good now, merging. Thanks! |
I needed to use the Metric Learners inside scikit Pipeline, which only calls .fit(X,y).
Therefore I renamed original .fit() to .fit_constraints(), added all of its parameters to constructor and created new .fit(), which uses the parameters from constructor to build constraints and then call .fit_constraints().
I understand this is a breaking change. If there is a better approach I want to hear it :)
This only affects methods which need special constraints: ITML, SDML, LSML, RCA