-
Notifications
You must be signed in to change notification settings - Fork 263
Create exact Principal Geodesic Analysis on the hyberbolic plane #1969
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
Create exact Principal Geodesic Analysis on the hyberbolic plane #1969
Conversation
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1969 +/- ##
==========================================
+ Coverage 91.53% 91.64% +0.12%
==========================================
Files 151 150 -1
Lines 13843 13834 -9
==========================================
+ Hits 12670 12677 +7
+ Misses 1173 1157 -16
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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 @alebrigant! Looking forward for your comments on the questions I've raised.
geomstats/learning/pca.py
Outdated
8000 | costs = self.space_ext.metric.dist(mn_ext, projections) ** 2 | |
return gs.sum(costs) | ||
|
||
costs = [ |
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.
we can probably vectorize here. (I can help you out)
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.
Sure, thanks !
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.
Can't vectorize actually. I think this is the best implementation.
geomstats/learning/pca.py
Outdated
angles_half_space = gs.linspace(0.0, 2 * gs.pi, self.n_vec) | ||
angles_half_space = gs.expand_dims(angles_half_space, axis=1) | ||
vectors_half_space = gs.hstack( | ||
(gs.cos(angles_half_space), gs.sin(angles_half_space)) | ||
) | ||
norms = self.half_space.metric.norm(vectors_half_space, mean_half_space) | ||
vectors_half_space = gs.einsum("ij,i->ij", vectors_half_space, 1 / norms) | ||
vectors_ext = self.space.half_space_to_extrinsic_tangent( | ||
vectors_half_space, mean_half_space | ||
) |
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.
What would be the difference if we get only the last tangent vector from vectors_half_space
, transform it to extrinsic, get the geodesic function directly from extrinsic, and then sample it uniformly between 0 and 1 with n_vec
?
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.
The difference is that you need to sample from tangent vectors in the extrinsic tangent space and I wanted to go fast so I didn't write down the formula (no need to look for one in the half-space). But it should certainly be changed at some point.
56b4446
to
78b30a1
Compare
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.
@alebrigant, a couple of very small changes due to naming and ready to go from my side.
geomstats/learning/pca.py
Outdated
costs = self.space_ext.metric.dist(mn_ext, projections) ** 2 | ||
return gs.sum(costs) | ||
|
||
costs = [ |
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.
Can't vectorize actually. I think this is the best implementation.
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 for your help Luis, it's all good for me !
2379f91
to
9c57390
Compare
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 @alebrigant! Merging.
This PR:
TODO: