8000 Create exact Principal Geodesic Analysis on the hyberbolic plane by alebrigant · Pull Request #1969 · geomstats/geomstats · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Merged
merged 21 commits into from
Mar 21, 2024

Conversation

alebrigant
Copy link
Collaborator

This PR:

  • creates exact principal geodesic analysis (PGA) in the hyperbolic space
  • adds changes of coordinates for tangent vectors in the hyperbolic space
  • updates the information geometry notebook by adding clustering and PGA in the space of normal distributions (=Poincaré half plane)

TODO:

  • extend hyperbolic PGA to higher dimensions (should be straightforward)
  • add exact PGA in the hypersphere (formulas available in the same reference)

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Copy link
codecov bot commented Mar 1, 2024

Codecov Report

Attention: Patch coverage is 47.95918% with 51 lines in your changes are missing coverage. Please review.

Project coverage is 91.64%. Comparing base (3a1c0c1) to head (9c57390).
Report is 72 commits behind head on main.

Files Patch % Lines
geomstats/learning/pca.py 18.00% 41 Missing ⚠️
geomstats/geometry/hyperboloid.py 12.50% 7 Missing ⚠️
geomstats/geometry/_hyperbolic.py 92.50% 3 Missing ⚠️
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     
Flag Coverage Δ
autograd ?
numpy 88.72% <47.96%> (-0.54%) ⬇️
pytorch 87.62% <47.96%> (+1.91%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator
@luisfpereira luisfpereira left a 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.

8000
costs = self.space_ext.metric.dist(mn_ext, projections) ** 2
return gs.sum(costs)

costs = [
Copy link
Collaborator

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)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, thanks !

Copy link
Collaborator

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.

Comment on lines 437 to 446
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
)
Copy link
Collaborator

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?

Copy link
Collaborator Author

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.

@luisfpereira luisfpereira force-pushed the alebrigant-hyperbolic-pga branch from 56b4446 to 78b30a1 Compare March 21, 2024 10:31
Copy link
Collaborator
@luisfpereira luisfpereira left a 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.

costs = self.space_ext.metric.dist(mn_ext, projections) ** 2
return gs.sum(costs)

costs = [
Copy link
Collaborator

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.

Copy link
Collaborator Author
@alebrigant alebrigant left a 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 !

@luisfpereira luisfpereira force-pushed the alebrigant-hyperbolic-pga branch from 2379f91 to 9c57390 Compare March 21, 2024 12:09
Copy link
Collaborator
@luisfpereira luisfpereira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @alebrigant! Merging.

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.

2 participants
0