Skip to content

[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

Merged
merged 19 commits into from
Mar 4, 2020

Conversation

grudloff
Copy link
Contributor

@grudloff grudloff commented Feb 14, 2020

[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:

  • add _TripletsClassifierMixin to base_metric.py
  • Tests
  • Documentation

@grudloff
Copy link
Contributor Author

I think the PR is ready for review now.

Copy link
Member

@bellet bellet left a 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,
Copy link
Member

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):
Copy link
Member

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

Copy link
Member

@bellet bellet left a 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!

Copy link
Member

@bellet bellet left a 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

@bellet bellet changed the title [WIP] Learning on Triplets [MRG] Learning on Triplets Mar 3, 2020
@bellet
Copy link
Member

bellet commented Mar 3, 2020

@perimosocordiae are you happy with the changes? If so I think we can merge

@perimosocordiae perimosocordiae merged commit 833e186 into scikit-learn-contrib:master Mar 4, 2020
@perimosocordiae
Copy link
Contributor

LGTM, merged. This is a very nice improvement, thanks @grudloff !

@grudloff
Copy link
Contributor Author

grudloff commented Mar 5, 2020

Great! :) Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants