-
Notifications
You must be signed in to change notification settings - Fork 228
[MRG] Learning on Triplets #279
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
[MRG] Learning on Triplets #279
Conversation
I think the PR is ready for review now. |
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.
Nice work. Most of my comments are small things.
The main thing missing is a properly tested version of generate_knntriplets
. It is quite important to make sure that this function behaves as expected (you can easily write some tests on toy data for which you know the correct neighbors) and handles some basic errors (in particular, when the size of the smallest class is too small compared to the value of k_genuine
, or the size of the dataset when ignoring the largest class is smaller than k_impostor
)
>>> [[4.5, 2.3], [2.1, 2.3], [7.3, 3.4]]]) | ||
>>> scml = SCML(random_state=42) | ||
>>> scml.fit(triplets) | ||
SCML(beta=1e-5, B=None, max_iter=100000, verbose=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.
This will have to be updated with the final API for SCML in #278
return X[triplets], None | ||
|
||
|
||
class mock_triplet_LSML(_BaseLSML, _TripletsClassifierMixin): |
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 is fine for now. we can remove it in #278 and replace it with SCML
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.
Thanks a lot, @grudloff! Besides minor phrasing issues, I think you need to expand a bit the test of the triplet generation function and we are good to go!
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! Unless someone (@perimosocordiae?) want to add something, I think we can merge
@perimosocordiae are you happy with the changes? If so I think we can merge |
LGTM, merged. This is a very nice improvement, thanks @grudloff ! |
Great! :) Thanks! |
[WIP] Learning on Triplets
This PR is intended to allow the implementation of algorithms that learn on triplets by adding the base class for this kind of learner. The semantic of triplets is similar to quadruplets but the positive and negative pairs are constructed with respect to the first element of the triplet, for this the added code follows closely the one for quadruplets.
The main reason for the creation of this is the implementation of SCML (PR #278) an algorithm that learns on triplets. This will also enable the implementation of future algorithms that learn on triplets.
TODO:
_TripletsClassifierMixin
tobase_metric.py