-
Notifications
You must be signed in to change notification settings - Fork 233
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
3. [WIP] OASIS algorithm implementation #330
Open
mvargas33
wants to merge
146
commits into
scikit-learn-contrib:master
Choose a base branch
from
mvargas33:feat-oasis
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+2,481
−363
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Trying to run tests with github actions
…s B weakly learners. Tests refactor.
mvargas33
commented
Nov 3, 2021
metric_learn/oasis.py
Outdated
Comment on lines
122
to
134
def _vi_matrix(self, triplet): | ||
""" | ||
Computes V_i, the gradient matrix in a triplet | ||
""" | ||
# (pi+ - pi-) | ||
diff = np.subtract(triplet[1], triplet[2]) # Shape (, d) | ||
result = [] | ||
|
||
# For each scalar in first triplet, multiply by the diff of pi+ and pi- | ||
for v in triplet[0]: | ||
result.append(v * diff) | ||
|
||
return np.array(result) # Shape (d, d) |
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 part is correct, just checked manually, but I've found a better way to compute it. This is equivalent to:
return np.outer(triplet[0], np.subtract(triplet[1], triplet[2]))
For d=100, and executing this function n=1.000.000 times, I get the following timings:
Current solution: 139.7970213389999 [s]
Using numpy outer: 13.34107805200074 [s]
I've changed it for this optimized approach
…ith partial fit now. Fix BilinearMocks. Moved indices test to test_utils.py
… the correct one. Changed indices var to private. RNG init in fit, not in constructor. Made n_iter a local varl in fit
… to avoid code duplication, trade-off with isinstance(). Added SCML basis that got lost in the list.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi!
I am currently implementing the OASIS algorithm and I open this PR to make the implementation transparent while working on it. Any discussion, question or comments is very welcomed.
This PR is under the WIP (Work In Progress) tag because as of now, I have a draft implementation of the algorithm out-of-the-package itself. It's a file in the root directory, with a test file in root as well.
Over these days I will move the algorithm to metric_learn folder to make it compatible with the current API. Same for testing.
Current testing only checks that nothing is broken, I'll make some test regarding KNN tasks to verify that the algorithm performs better at least for a handmade toy test.
This PR depends on the Bilinear PR #329 acceptance beforehand.