-
Notifications
You must be signed in to change notification settings - Fork 228
Disallow 0 on Triplets predictions #331
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
Disallow 0 on Triplets predictions #331
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.
Thanks @mvargas33. I have not looked at the tests yet (some tests are failing)
a44dfdc
to
15899ab
Compare
This PR is ready to be merged |
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.
See minor comments above.
If you don't merge the new test with test_predict_only_one_or_minus_one
, please move it right after it as they are quite related.
Resolved all the small comments |
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!
Right now, the zero value is allowed when predicting triplets, because of
np.sign
wich returns -1 if the input is below zero, +1 if the input is higher than zero, and 0 if the input is zero.Triplets of the form: (x, y, y), (x, x, x) and (x, u, v), with u and v orthogonal to x with the same norm, cause trouble.
This is because the distance between x and the second point, x and third point is the same, causing
decision_function
to be zero, and then causingpredict
to be zero in the_TripletsClassifierMixin
.For bilinear similarity it's even more relaxed, as the norm of u and v does not need to be the same.
By definition, the semantic of a triplet says that the distance between the first and the second point should be strictly higher than the distance between the first and the third point, then any zero prediction is invalid.
I propose to force zero predictions to be -1 instead, as the definition of a triplet is not satisfied.
In practice, there should not be that many border cases.
Finally, I also made a test to show this problem.