summaryrefslogtreecommitdiff
path: root/examples/gromov/plot_barycenter_fgw.py
diff options
context:
space:
mode:
authorOleksii Kachaiev <kachayev@gmail.com>2023-05-03 10:36:09 +0200
committerGitHub <noreply@github.com>2023-05-03 10:36:09 +0200
commit2aeb591be6b19a93f187516495ed15f1a47be925 (patch)
tree9a6f759856a3f6b2d7c6db3514927ba3e5af10b5 /examples/gromov/plot_barycenter_fgw.py
parent8a7035bdaa5bb164d1c16febbd83650d1fb6d393 (diff)
[DOC] Corrected spelling errors (#467)
* Fix typos in docstrings and examples * A few more fixes * Fix ref for `center_ot_dual` function * Another typo * Fix titles formatting * Explicit empty line after math blocks * Typo: asymmetric * Fix code cell formatting for 1D barycenters * Empirical * Fix indentation for references * Fixed all WARNINGs about title formatting * Fix empty lines after math blocks * Fix whitespace line * Update changelog * Consistent Gromov-Wasserstein * More Gromov-Wasserstein consistency --------- Co-authored-by: RĂ©mi Flamary <remi.flamary@gmail.com>
Diffstat (limited to 'examples/gromov/plot_barycenter_fgw.py')
-rw-r--r--examples/gromov/plot_barycenter_fgw.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/examples/gromov/plot_barycenter_fgw.py b/examples/gromov/plot_barycenter_fgw.py
index dc3c6aa..3b5db8b 100644
--- a/examples/gromov/plot_barycenter_fgw.py
+++ b/examples/gromov/plot_barycenter_fgw.py
@@ -34,8 +34,8 @@ from ot.gromov import fgw_barycenters
def find_thresh(C, inf=0.5, sup=3, step=10):
""" Trick to find the adequate thresholds from where value of the C matrix are considered close enough to say that nodes are connected
- Tthe threshold is found by a linesearch between values "inf" and "sup" with "step" thresholds tested.
- The optimal threshold is the one which minimizes the reconstruction error between the shortest_path matrix coming from the thresholded adjency matrix
+ The threshold is found by a linesearch between values "inf" and "sup" with "step" thresholds tested.
+ The optimal threshold is the one which minimizes the reconstruction error between the shortest_path matrix coming from the thresholded adjacency matrix
and the original matrix.
Parameters
----------
@@ -51,15 +51,15 @@ def find_thresh(C, inf=0.5, sup=3, step=10):
dist = []
search = np.linspace(inf, sup, step)
for thresh in search:
- Cprime = sp_to_adjency(C, 0, thresh)
+ Cprime = sp_to_adjacency(C, 0, thresh)
SC = shortest_path(Cprime, method='D')
SC[SC == float('inf')] = 100
dist.append(np.linalg.norm(SC - C))
return search[np.argmin(dist)], dist
-def sp_to_adjency(C, threshinf=0.2, threshsup=1.8):
- """ Thresholds the structure matrix in order to compute an adjency matrix.
+def sp_to_adjacency(C, threshinf=0.2, threshsup=1.8):
+ """ Thresholds the structure matrix in order to compute an adjacency matrix.
All values between threshinf and threshsup are considered representing connected nodes and set to 1. Else are set to 0
Parameters
----------
@@ -174,7 +174,7 @@ A, C, log = fgw_barycenters(sizebary, Ys, Cs, ps, lambdas, alpha=0.95, log=True)
# -------------------------
#%% Create the barycenter
-bary = nx.from_numpy_array(sp_to_adjency(C, threshinf=0, threshsup=find_thresh(C, sup=100, step=100)[0]))
+bary = nx.from_numpy_array(sp_to_adjacency(C, threshinf=0, threshsup=find_thresh(C, sup=100, step=100)[0]))
for i, v in enumerate(A.ravel()):
bary.add_node(i, attr_name=v)