Skip to content
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

Benedict: Visualization of manifolds of categorical distributions #1813

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

Benleeee
Copy link
Collaborator

@Benleeee Benleeee commented Jan 30, 2023

Checklist

  • My pull request has a clear and explanatory title.
  • If necessary, my code is vectorized.
  • I added appropriate unit tests.
  • I made sure the code passes all unit tests. (refer to comment below)
  • My PR follows PEP8 guidelines. (refer to comment below)
  • My PR follows geomstats coding style and API.
  • My code is properly documented and I made sure the documentation renders properly. (Link)
  • I linked to issues and PRs that are relevant to this PR.

Description

Issue

Additional context

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@ninamiolane ninamiolane changed the title Benedict Benedict: Visualization of manifolds of categorical distributions Feb 1, 2023
Copy link
Collaborator

@ninamiolane ninamiolane left a comment

Choose a reason for hiding this comment

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

Changes to be made before we can merge:

  • no CamelCase in python file names + use simpler file name: CategoricalDistributionsManifold.py --> categorical.py (and likewise for the notebook)
  • test_visualization_manifold_of_categorical_distributions.py --> test_visualization_categorical.py
  • the folder image containing the images needs to be removed, the images contained within it need to go to the existing notebooks/figures/, and the text in the notebook should be adapted accordingly.
  • add test functions for functions that are in categorical.py but not tests in the test file.
  • Copy-paste the "setup" section of this example so that the notebook runs.

@@ -0,0 +1,484 @@
import numpy as np
Copy link
Collaborator

Choose a reason for hiding this comment

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

Missing docstring at the top of file

import numpy as np
from geomstats.information_geometry.categorical import (
CategoricalDistributions, CategoricalMetric)
from matplotlib import pyplot as plt
Copy link
Collaborator

Choose a reason for hiding this comment

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

import matplotlib.pyplot as plt

from mpl_toolkits.mplot3d.art3d import Poly3DCollection


class CategoricalDistributionsManifold:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Rename it CategoricalSimplex

"""

def __init__(self, dim):
"""Construct a CategoricalDistributionsManifold object.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Change docstring following my comment on renaming to CategoricalSimplex

def plot(self):
"""Plot the 2D or 3D Manifold.

Plot the 2D Manifold as a regular 2-simplex(triangle) or
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: add space before (

"""Plot the 2D or 3D Manifold.

Plot the 2D Manifold as a regular 2-simplex(triangle) or
the 3D Manifold as a regular 3-simplex(tetrahedral).
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ditto


Construct a CategoricalDistributionsManifold with a given dimension.

Parameters:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove : and corresponding underline

operation="Exp",
)

def plot_helper(self, end_point, base_point, tangent_vec, operation):
Copy link
Collaborator

Choose a reason for hiding this comment

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

rename to _plot_two_points_and_a_vector

Manifold"
)
if self.dim == 3:
# Plot in Matplotlib
Copy link
Collaborator

Choose a reason for hiding this comment

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

Rm unnecessary comment

@@ -0,0 +1,48 @@
"""Unit tests for visualization."""
Copy link
Collaborator

Choose a reason for hiding this comment

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

for visualization of the manifold of categorical distributions

matplotlib.use("Agg") # NOQA


class TestVisualizationManifoldOfCategoricalDistributions(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Rename to TestVisualizationCategorical

self.CD2.scatter(self.n_samples)
self.CD3.scatter(self.n_samples)

def test_plot_geodesic(self):
Copy link
Collaborator

Choose a reason for hiding this comment

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

missing test_plot_log, test_plot_exp, test__plot_two_points_and_a_vector

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

Successfully merging this pull request may close these issues.

None yet

2 participants