summaryrefslogtreecommitdiff
path: root/examples
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
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')
-rw-r--r--examples/backends/plot_dual_ot_pytorch.py6
-rw-r--r--examples/backends/plot_optim_gromov_pytorch.py20
-rw-r--r--examples/backends/plot_sliced_wass_grad_flow_pytorch.py10
-rw-r--r--examples/backends/plot_ssw_unif_torch.py2
-rw-r--r--examples/backends/plot_stoch_continuous_ot_pytorch.py10
-rw-r--r--examples/backends/plot_unmix_optim_torch.py6
-rw-r--r--examples/backends/plot_wass1d_torch.py2
-rw-r--r--examples/backends/plot_wass2_gan_torch.py6
-rw-r--r--examples/barycenters/plot_barycenter_1D.py3
-rw-r--r--examples/barycenters/plot_free_support_barycenter.py8
-rw-r--r--examples/barycenters/plot_generalized_free_support_barycenter.py2
-rw-r--r--examples/domain-adaptation/plot_otda_semi_supervised.py4
-rw-r--r--examples/gromov/plot_barycenter_fgw.py12
-rw-r--r--examples/gromov/plot_fgw.py2
-rw-r--r--examples/gromov/plot_gromov.py2
-rwxr-xr-xexamples/gromov/plot_gromov_barycenter.py2
-rwxr-xr-xexamples/gromov/plot_gromov_wasserstein_dictionary_learning.py24
-rw-r--r--examples/gromov/plot_semirelaxed_fgw.py16
-rw-r--r--examples/others/plot_WeakOT_VS_OT.py2
-rw-r--r--examples/others/plot_factored_coupling.py6
-rw-r--r--examples/others/plot_logo.py2
-rw-r--r--examples/others/plot_screenkhorn_1D.py4
-rw-r--r--examples/others/plot_stochastic.py6
-rw-r--r--examples/plot_Intro_OT.py6
-rw-r--r--examples/plot_OT_1D_smooth.py2
-rw-r--r--examples/plot_OT_2D_samples.py6
-rw-r--r--examples/plot_OT_L1_vs_L2.py2
-rw-r--r--examples/plot_compute_emd.py4
-rw-r--r--examples/sliced-wasserstein/plot_variance.py2
-rw-r--r--examples/sliced-wasserstein/plot_variance_ssw.py2
-rw-r--r--examples/unbalanced-partial/plot_UOT_barycenter_1D.py2
-rw-r--r--examples/unbalanced-partial/plot_regpath.py12
32 files changed, 98 insertions, 97 deletions
diff --git a/examples/backends/plot_dual_ot_pytorch.py b/examples/backends/plot_dual_ot_pytorch.py
index d3f7a66..67c7077 100644
--- a/examples/backends/plot_dual_ot_pytorch.py
+++ b/examples/backends/plot_dual_ot_pytorch.py
@@ -100,7 +100,7 @@ pl.xlabel("Iterations")
Ge = ot.stochastic.plan_dual_entropic(u, v, xs, xt, reg=reg)
# %%
-# Plot teh estimated entropic OT plan
+# Plot the estimated entropic OT plan
# -----------------------------------
pl.figure(3, (10, 5))
@@ -114,7 +114,7 @@ pl.title('Source and target distributions')
# %%
# Estimating dual variables for quadratic OT
-# -----------------------------------------
+# ------------------------------------------
u = torch.randn(n_source_samples, requires_grad=True)
v = torch.randn(n_source_samples, requires_grad=True)
@@ -157,7 +157,7 @@ Gq = ot.stochastic.plan_dual_quadratic(u, v, xs, xt, reg=reg)
# %%
# Plot the estimated quadratic OT plan
-# -----------------------------------
+# ------------------------------------
pl.figure(5, (10, 5))
pl.clf()
diff --git a/examples/backends/plot_optim_gromov_pytorch.py b/examples/backends/plot_optim_gromov_pytorch.py
index cdc1587..0ae2890 100644
--- a/examples/backends/plot_optim_gromov_pytorch.py
+++ b/examples/backends/plot_optim_gromov_pytorch.py
@@ -1,7 +1,7 @@
r"""
-=================================
+=======================================================
Optimizing the Gromov-Wasserstein distance with PyTorch
-=================================
+=======================================================
In this example, we use the pytorch backend to optimize the Gromov-Wasserstein
(GW) loss between two graphs expressed as empirical distribution.
@@ -11,7 +11,7 @@ graph so that it minimizes the GW with a given Stochastic Block Model graph.
We can see that this actually recovers the proportion of classes in the SBM
and allows for an accurate clustering of the nodes using the GW optimal plan.
-In the second part, we optimize simultaneously the weights and the sructure of
+In the second part, we optimize simultaneously the weights and the structure of
the template graph which allows us to perform graph compression and to recover
other properties of the SBM.
@@ -38,7 +38,7 @@ from ot.gromov import gromov_wasserstein2
# %%
# Graph generation
-# ---------------
+# ----------------
rng = np.random.RandomState(42)
@@ -95,8 +95,8 @@ pl.axis("off")
# %%
# Optimizing GW w.r.t. the weights on a template structure
-# ------------------------------------------------
-# The adajacency matrix C1 is block diagonal with 3 blocks. We want to
+# --------------------------------------------------------
+# The adjacency matrix C1 is block diagonal with 3 blocks. We want to
# optimize the weights of a simple template C0=eye(3) and see if we can
# recover the proportion of classes from the SBM (up to a permutation).
@@ -155,7 +155,7 @@ print("True proportions : ", ratio)
# %%
# Community clustering with uniform and estimated weights
-# --------------------------------------------
+# -------------------------------------------------------
# The GW OT plan can be used to perform a clustering of the nodes of a graph
# when computing the GW with a simple template like C0 by labeling nodes in
# the original graph using by the index of the noe in the template receiving
@@ -193,7 +193,7 @@ pl.axis("off")
# classes
-def graph_compession_gw(nb_nodes, C2, a2, nb_iter_max=100, lr=1e-2):
+def graph_compression_gw(nb_nodes, C2, a2, nb_iter_max=100, lr=1e-2):
""" solve min_a GW(C1,C2,a, a2) by gradient descent"""
# use pyTorch for our data
@@ -237,8 +237,8 @@ def graph_compession_gw(nb_nodes, C2, a2, nb_iter_max=100, lr=1e-2):
nb_nodes = 3
-a0_est2, C0_est2, loss_iter2 = graph_compession_gw(nb_nodes, C1, ot.unif(n),
- nb_iter_max=100, lr=5e-2)
+a0_est2, C0_est2, loss_iter2 = graph_compression_gw(nb_nodes, C1, ot.unif(n),
+ nb_iter_max=100, lr=5e-2)
pl.figure(4)
pl.plot(loss_iter2)
diff --git a/examples/backends/plot_sliced_wass_grad_flow_pytorch.py b/examples/backends/plot_sliced_wass_grad_flow_pytorch.py
index f00de50..07a4926 100644
--- a/examples/backends/plot_sliced_wass_grad_flow_pytorch.py
+++ b/examples/backends/plot_sliced_wass_grad_flow_pytorch.py
@@ -1,16 +1,16 @@
r"""
-=================================
+============================================================
Sliced Wasserstein barycenter and gradient flow with PyTorch
-=================================
+============================================================
-In this exemple we use the pytorch backend to optimize the sliced Wasserstein
+In this example we use the pytorch backend to optimize the sliced Wasserstein
loss between two empirical distributions [31].
In the first example one we perform a
gradient flow on the support of a distribution that minimize the sliced
-Wassersein distance as poposed in [36].
+Wasserstein distance as proposed in [36].
-In the second exemple we optimize with a gradient descent the sliced
+In the second example we optimize with a gradient descent the sliced
Wasserstein barycenter between two distributions as in [31].
[31] Bonneel, Nicolas, et al. "Sliced and radon wasserstein barycenters of
diff --git a/examples/backends/plot_ssw_unif_torch.py b/examples/backends/plot_ssw_unif_torch.py
index 7ccc2af..afe3fa6 100644
--- a/examples/backends/plot_ssw_unif_torch.py
+++ b/examples/backends/plot_ssw_unif_torch.py
@@ -119,7 +119,7 @@ for i in range(9):
# %%
# Animate trajectories of generated samples along iteration
-# -------------------------------------------------------
+# ---------------------------------------------------------
pl.figure(4, (8, 8))
diff --git a/examples/backends/plot_stoch_continuous_ot_pytorch.py b/examples/backends/plot_stoch_continuous_ot_pytorch.py
index 6d9b916..714a5d3 100644
--- a/examples/backends/plot_stoch_continuous_ot_pytorch.py
+++ b/examples/backends/plot_stoch_continuous_ot_pytorch.py
@@ -125,8 +125,8 @@ pl.xlabel("Iterations")
# %%
-# Plot the density on arget for a given source sample
-# ---------------------------------------------------
+# Plot the density on target for a given source sample
+# ----------------------------------------------------
nv = 100
@@ -155,7 +155,7 @@ Gg = Gg.reshape((nv, nv)).detach().numpy()
pl.scatter(Xs[:nvisu, 0], Xs[:nvisu, 1], marker='+', zorder=2, alpha=0.05)
pl.scatter(Xt[:nvisu, 0], Xt[:nvisu, 1], marker='o', zorder=2, alpha=0.05)
pl.scatter(Xs[iv:iv + 1, 0], Xs[iv:iv + 1, 1], s=100, marker='+', label='Source sample', zorder=2, alpha=1, color='C0')
-pl.pcolormesh(XX, YY, Gg, cmap='Greens', label='Density of transported sourec sample')
+pl.pcolormesh(XX, YY, Gg, cmap='Greens', label='Density of transported source sample')
pl.legend(loc=0)
ax_bounds = pl.axis()
pl.title('Density of transported source sample')
@@ -169,7 +169,7 @@ Gg = Gg.reshape((nv, nv)).detach().numpy()
pl.scatter(Xs[:nvisu, 0], Xs[:nvisu, 1], marker='+', zorder=2, alpha=0.05)
pl.scatter(Xt[:nvisu, 0], Xt[:nvisu, 1], marker='o', zorder=2, alpha=0.05)
pl.scatter(Xs[iv:iv + 1, 0], Xs[iv:iv + 1, 1], s=100, marker='+', label='Source sample', zorder=2, alpha=1, color='C0')
-pl.pcolormesh(XX, YY, Gg, cmap='Greens', label='Density of transported sourec sample')
+pl.pcolormesh(XX, YY, Gg, cmap='Greens', label='Density of transported source sample')
pl.legend(loc=0)
ax_bounds = pl.axis()
pl.title('Density of transported source sample')
@@ -183,7 +183,7 @@ Gg = Gg.reshape((nv, nv)).detach().numpy()
pl.scatter(Xs[:nvisu, 0], Xs[:nvisu, 1], marker='+', zorder=2, alpha=0.05)
pl.scatter(Xt[:nvisu, 0], Xt[:nvisu, 1], marker='o', zorder=2, alpha=0.05)
pl.scatter(Xs[iv:iv + 1, 0], Xs[iv:iv + 1, 1], s=100, marker='+', label='Source sample', zorder=2, alpha=1, color='C0')
-pl.pcolormesh(XX, YY, Gg, cmap='Greens', label='Density of transported sourec sample')
+pl.pcolormesh(XX, YY, Gg, cmap='Greens', label='Density of transported source sample')
pl.legend(loc=0)
ax_bounds = pl.axis()
pl.title('Density of transported source sample')
diff --git a/examples/backends/plot_unmix_optim_torch.py b/examples/backends/plot_unmix_optim_torch.py
index 9ae66e9..e47a5e0 100644
--- a/examples/backends/plot_unmix_optim_torch.py
+++ b/examples/backends/plot_unmix_optim_torch.py
@@ -135,7 +135,7 @@ for i in range(niter):
##############################################################################
# Estimated weights and convergence of the objective
-# ---------------------------------------------------
+# --------------------------------------------------
we = w.detach().numpy()
print('Estimated mixture:', we)
@@ -147,8 +147,8 @@ pl.title('Wasserstein distance')
pl.xlabel("Iterations")
##############################################################################
-# Ploting the reweighted source distribution
-# ------------------------------------------
+# Plotting the reweighted source distribution
+# -------------------------------------------
pl.figure(3)
diff --git a/examples/backends/plot_wass1d_torch.py b/examples/backends/plot_wass1d_torch.py
index cd8e2fd..5a85795 100644
--- a/examples/backends/plot_wass1d_torch.py
+++ b/examples/backends/plot_wass1d_torch.py
@@ -94,7 +94,7 @@ pl.show()
# %%
# Wasserstein barycenter
-# ---------
+# ----------------------
# In this example, we consider the following Wasserstein barycenter problem
# $$ \\eta^* = \\min_\\eta\;\;\; (1-t)W(\\mu,\\eta) + tW(\\eta,\\nu)$$
# where :math:`\\mu` and :math:`\\nu` are reference 1D measures, and :math:`t`
diff --git a/examples/backends/plot_wass2_gan_torch.py b/examples/backends/plot_wass2_gan_torch.py
index cc82f4f..f39d186 100644
--- a/examples/backends/plot_wass2_gan_torch.py
+++ b/examples/backends/plot_wass2_gan_torch.py
@@ -19,13 +19,13 @@ optimization problem:
In practice we do not have access to the full distribution :math:`\mu_d` but
-samples and we cannot compute the Wasserstein distance for lare dataset.
+samples and we cannot compute the Wasserstein distance for large dataset.
[Arjovsky2017] proposed to approximate the dual potential of Wasserstein 1
with a neural network recovering an optimization problem similar to GAN.
In this example
we will optimize the expectation of the Wasserstein distance over minibatches
at each iterations as proposed in [Genevay2018]. Optimizing the Minibatches
-of the Wasserstein distance has been studied in[Fatras2019].
+of the Wasserstein distance has been studied in [Fatras2019].
[Arjovsky2017] Arjovsky, M., Chintala, S., & Bottou, L. (2017, July).
Wasserstein generative adversarial networks. In International conference
@@ -183,7 +183,7 @@ for i in range(9):
# %%
# Animate trajectories of generated samples along iteration
-# -------------------------------------------------------
+# ---------------------------------------------------------
pl.figure(4, (8, 8))
diff --git a/examples/barycenters/plot_barycenter_1D.py b/examples/barycenters/plot_barycenter_1D.py
index 8096245..40dc444 100644
--- a/examples/barycenters/plot_barycenter_1D.py
+++ b/examples/barycenters/plot_barycenter_1D.py
@@ -4,7 +4,7 @@
1D Wasserstein barycenter demo
==============================
-This example illustrates the computation of regularized Wassersyein Barycenter
+This example illustrates the computation of regularized Wasserstein Barycenter
as proposed in [3].
@@ -80,6 +80,7 @@ plt.show()
##############################################################################
# Barycentric interpolation
# -------------------------
+
#%% barycenter interpolation
n_alpha = 11
diff --git a/examples/barycenters/plot_free_support_barycenter.py b/examples/barycenters/plot_free_support_barycenter.py
index f4a13dd..b6a4a11 100644
--- a/examples/barycenters/plot_free_support_barycenter.py
+++ b/examples/barycenters/plot_free_support_barycenter.py
@@ -5,7 +5,7 @@
========================================================
Illustration of 2D Wasserstein and Sinkhorn barycenters if distributions are weighted
-sum of diracs.
+sum of Diracs.
"""
@@ -50,7 +50,7 @@ pl.title('Distributions')
# %%
# Compute free support Wasserstein barycenter
-# -------------------------------
+# -------------------------------------------
k = 200 # number of Diracs of the barycenter
X_init = np.random.normal(0., 1., (k, d)) # initial Dirac locations
@@ -60,7 +60,7 @@ X = ot.lp.free_support_barycenter(measures_locations, measures_weights, X_init,
# %%
# Plot the Wasserstein barycenter
-# ---------
+# -------------------------------
pl.figure(2, (8, 3))
pl.scatter(x1[:, 0], x1[:, 1], alpha=0.5)
@@ -81,7 +81,7 @@ X = ot.bregman.free_support_sinkhorn_barycenter(measures_locations, measures_wei
# %%
# Plot the Wasserstein barycenter
-# ---------
+# -------------------------------
pl.figure(2, (8, 3))
pl.scatter(x1[:, 0], x1[:, 1], alpha=0.5)
diff --git a/examples/barycenters/plot_generalized_free_support_barycenter.py b/examples/barycenters/plot_generalized_free_support_barycenter.py
index e685ec7..a4d081b 100644
--- a/examples/barycenters/plot_generalized_free_support_barycenter.py
+++ b/examples/barycenters/plot_generalized_free_support_barycenter.py
@@ -57,7 +57,7 @@ weights = np.array([1 / 3, 1 / 3, 1 / 3])
# Number of barycenter points to compute
n_samples_bary = 150
-# Send the input measures into 3D space for visualisation
+# Send the input measures into 3D space for visualization
X_visu = [Xi @ Pi for (Xi, Pi) in zip(X_list, P_list)]
# Plot the input data
diff --git a/examples/domain-adaptation/plot_otda_semi_supervised.py b/examples/domain-adaptation/plot_otda_semi_supervised.py
index 478c3b8..278c8dd 100644
--- a/examples/domain-adaptation/plot_otda_semi_supervised.py
+++ b/examples/domain-adaptation/plot_otda_semi_supervised.py
@@ -50,7 +50,7 @@ ot_sinkhorn_semi = ot.da.SinkhornTransport(reg_e=1e-1)
ot_sinkhorn_semi.fit(Xs=Xs, Xt=Xt, ys=ys, yt=yt)
transp_Xs_sinkhorn_semi = ot_sinkhorn_semi.transform(Xs=Xs)
-# semi supervised DA uses available labaled target samples to modify the cost
+# semi supervised DA uses available labeled target samples to modify the cost
# matrix involved in the OT problem. The cost of transporting a source sample
# of class A onto a target sample of class B != A is set to infinite, or a
# very large value
@@ -92,7 +92,7 @@ pl.subplot(2, 2, 4)
pl.imshow(ot_sinkhorn_semi.cost_, interpolation='nearest')
pl.xticks([])
pl.yticks([])
-pl.title('Cost matrix - semisupervised DA')
+pl.title('Cost matrix - semi-supervised DA')
pl.tight_layout()
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)
diff --git a/examples/gromov/plot_fgw.py b/examples/gromov/plot_fgw.py
index 5475fb3..bf10de6 100644
--- a/examples/gromov/plot_fgw.py
+++ b/examples/gromov/plot_fgw.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""
==============================
-Plot Fused-gromov-Wasserstein
+Plot Fused-Gromov-Wasserstein
==============================
This example illustrates the computation of FGW for 1D measures [18].
diff --git a/examples/gromov/plot_gromov.py b/examples/gromov/plot_gromov.py
index 05074dc..afb5bdc 100644
--- a/examples/gromov/plot_gromov.py
+++ b/examples/gromov/plot_gromov.py
@@ -3,7 +3,7 @@
==========================
Gromov-Wasserstein example
==========================
-This example is designed to show how to use the Gromov-Wassertsein distance
+This example is designed to show how to use the Gromov-Wasserstein distance
computation in POT.
"""
diff --git a/examples/gromov/plot_gromov_barycenter.py b/examples/gromov/plot_gromov_barycenter.py
index 08ec610..1b9abbf 100755
--- a/examples/gromov/plot_gromov_barycenter.py
+++ b/examples/gromov/plot_gromov_barycenter.py
@@ -36,7 +36,7 @@ import ot
def smacof_mds(C, dim, max_iter=3000, eps=1e-9):
"""
Returns an interpolated point cloud following the dissimilarity matrix C
- using SMACOF multidimensional scaling (MDS) in specific dimensionned
+ using SMACOF multidimensional scaling (MDS) in specific dimensioned
target space
Parameters
diff --git a/examples/gromov/plot_gromov_wasserstein_dictionary_learning.py b/examples/gromov/plot_gromov_wasserstein_dictionary_learning.py
index 7585944..8cccf88 100755
--- a/examples/gromov/plot_gromov_wasserstein_dictionary_learning.py
+++ b/examples/gromov/plot_gromov_wasserstein_dictionary_learning.py
@@ -1,11 +1,11 @@
# -*- coding: utf-8 -*-
r"""
-=================================
+=====================================================
(Fused) Gromov-Wasserstein Linear Dictionary Learning
-=================================
+=====================================================
-In this exemple, we illustrate how to learn a Gromov-Wasserstein dictionary on
+In this example, we illustrate how to learn a Gromov-Wasserstein dictionary on
a dataset of structured data such as graphs, denoted
:math:`\{ \mathbf{C_s} \}_{s \in [S]}` where every nodes have uniform weights.
Given a dictionary :math:`\mathbf{C_{dict}}` composed of D structures of a fixed
@@ -49,7 +49,7 @@ from networkx.generators.community import stochastic_block_model as sbm
#############################################################################
#
# Generate a dataset composed of graphs following Stochastic Block models of 1, 2 and 3 clusters.
-# ---------------------------------------------
+# -----------------------------------------------------------------------------------------------
np.random.seed(42)
@@ -112,8 +112,8 @@ pl.show()
#############################################################################
#
-# Estimate the gromov-wasserstein dictionary from the dataset
-# ---------------------------------------------
+# Estimate the Gromov-Wasserstein dictionary from the dataset
+# -----------------------------------------------------------
np.random.seed(0)
@@ -144,7 +144,7 @@ pl.show()
#############################################################################
#
# Visualization of the estimated dictionary atoms
-# ---------------------------------------------
+# -----------------------------------------------
# Continuous connections between nodes of the atoms are colored in shades of grey (1: dark / 2: white)
@@ -169,7 +169,7 @@ pl.show()
#############################################################################
#
# Visualization of the embedding space
-# ---------------------------------------------
+# ------------------------------------
unmixings = []
reconstruction_errors = []
@@ -217,7 +217,7 @@ pl.show()
#############################################################################
#
# Endow the dataset with node features
-# ---------------------------------------------
+# ------------------------------------
# We follow this feature assignment on all nodes of a graph depending on its label/number of clusters
# 1 cluster --> 0 as nodes feature
# 2 clusters --> 1 as nodes feature
@@ -257,7 +257,7 @@ pl.show()
#############################################################################
#
# Estimate a Fused Gromov-Wasserstein dictionary from the dataset of attributed graphs
-# ---------------------------------------------
+# ------------------------------------------------------------------------------------
np.random.seed(0)
ps = [ot.unif(C.shape[0]) for C in dataset]
D = 3 # 6 atoms instead of 3
@@ -286,7 +286,7 @@ pl.show()
#############################################################################
#
# Visualization of the estimated dictionary atoms
-# ---------------------------------------------
+# -----------------------------------------------
pl.figure(7, (12, 8))
pl.clf()
@@ -313,7 +313,7 @@ pl.show()
#############################################################################
#
# Visualization of the embedding space
-# ---------------------------------------------
+# ------------------------------------
unmixings = []
reconstruction_errors = []
diff --git a/examples/gromov/plot_semirelaxed_fgw.py b/examples/gromov/plot_semirelaxed_fgw.py
index ef4b286..579f23d 100644
--- a/examples/gromov/plot_semirelaxed_fgw.py
+++ b/examples/gromov/plot_semirelaxed_fgw.py
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
"""
-==========================
+===============================================
Semi-relaxed (Fused) Gromov-Wasserstein example
-==========================
+===============================================
This example is designed to show how to use the semi-relaxed Gromov-Wasserstein
and the semi-relaxed Fused Gromov-Wasserstein divergences.
@@ -34,7 +34,7 @@ from networkx.generators.community import stochastic_block_model as sbm
#############################################################################
#
# Generate two graphs following Stochastic Block models of 2 and 3 clusters.
-# ---------------------------------------------
+# --------------------------------------------------------------------------
N2 = 20 # 2 communities
@@ -85,7 +85,7 @@ for i, j in G3.edges():
#############################################################################
#
# Compute their semi-relaxed Gromov-Wasserstein divergences
-# ---------------------------------------------
+# ---------------------------------------------------------
# 0) GW(C2, h2, C3, h3) for reference
OT, log = gromov_wasserstein(C2, C3, h2, h3, symmetric=True, log=True)
@@ -110,7 +110,7 @@ print('srGW(C3, h3, C2) = ', srgw_32)
#############################################################################
#
# Visualization of the semi-relaxed Gromov-Wasserstein matchings
-# ---------------------------------------------
+# --------------------------------------------------------------
#
# We color nodes of the graph on the right - then project its node colors
# based on the optimal transport plan from the srGW matching
@@ -226,7 +226,7 @@ pl.show()
#############################################################################
#
# Add node features
-# ---------------------------------------------
+# -----------------
# We add node features with given mean - by clusters
# and inversely proportional to clusters' intra-connectivity
@@ -242,7 +242,7 @@ for i, c in enumerate(part_G3):
#############################################################################
#
# Compute their semi-relaxed Fused Gromov-Wasserstein divergences
-# ---------------------------------------------
+# ---------------------------------------------------------------
alpha = 0.5
# Compute pairwise euclidean distance between node features
@@ -272,7 +272,7 @@ print('srGW(C3, F3, h3, C2, F2) = ', srfgw_32)
#############################################################################
#
# Visualization of the semi-relaxed Fused Gromov-Wasserstein matchings
-# ---------------------------------------------
+# --------------------------------------------------------------------
#
# We color nodes of the graph on the right - then project its node colors
# based on the optimal transport plan from the srFGW matching
diff --git a/examples/others/plot_WeakOT_VS_OT.py b/examples/others/plot_WeakOT_VS_OT.py
index a29c875..e3164ba 100644
--- a/examples/others/plot_WeakOT_VS_OT.py
+++ b/examples/others/plot_WeakOT_VS_OT.py
@@ -5,7 +5,7 @@ Weak Optimal Transport VS exact Optimal Transport
====================================================
Illustration of 2D optimal transport between distributions that are weighted
-sum of diracs. The OT matrix is plotted with the samples.
+sum of Diracs. The OT matrix is plotted with the samples.
"""
diff --git a/examples/others/plot_factored_coupling.py b/examples/others/plot_factored_coupling.py
index b5b1c9f..02074d7 100644
--- a/examples/others/plot_factored_coupling.py
+++ b/examples/others/plot_factored_coupling.py
@@ -47,8 +47,8 @@ pl.title('Source and target distributions')
# %%
-# Compute Factore OT and exact OT solutions
-# --------------------------------------
+# Compute Factored OT and exact OT solutions
+# ------------------------------------------
#%% EMD
M = ot.dist(xs, xt)
@@ -61,7 +61,7 @@ Ga, Gb, xb = ot.factored_optimal_transport(xs, xt, a, b, r=4)
# %%
# Plot factored OT and exact OT solutions
-# --------------------------------------
+# ---------------------------------------
pl.figure(2, (14, 4))
diff --git a/examples/others/plot_logo.py b/examples/others/plot_logo.py
index bb4f640..b032801 100644
--- a/examples/others/plot_logo.py
+++ b/examples/others/plot_logo.py
@@ -8,7 +8,7 @@ Logo of the POT toolbox
In this example we plot the logo of the POT toolbox.
This logo is that it is done 100% in Python and generated using
-matplotlib and ploting teh solution of the EMD solver from POT.
+matplotlib and plotting the solution of the EMD solver from POT.
"""
diff --git a/examples/others/plot_screenkhorn_1D.py b/examples/others/plot_screenkhorn_1D.py
index 2023649..3640b88 100644
--- a/examples/others/plot_screenkhorn_1D.py
+++ b/examples/others/plot_screenkhorn_1D.py
@@ -62,8 +62,8 @@ ot.plot.plot1D_mat(a, b, M, 'Cost matrix M')
# Screenkhorn
lambd = 2e-03 # entropy parameter
-ns_budget = 30 # budget number of points to be keeped in the source distribution
-nt_budget = 30 # budget number of points to be keeped in the target distribution
+ns_budget = 30 # budget number of points to be kept in the source distribution
+nt_budget = 30 # budget number of points to be kept in the target distribution
G_screen = screenkhorn(a, b, M, lambd, ns_budget, nt_budget, uniform=False, restricted=True, verbose=True)
pl.figure(4, figsize=(5, 5))
diff --git a/examples/others/plot_stochastic.py b/examples/others/plot_stochastic.py
index 3a1ef31..f3afb0b 100644
--- a/examples/others/plot_stochastic.py
+++ b/examples/others/plot_stochastic.py
@@ -3,7 +3,7 @@
Stochastic examples
===================
-This example is designed to show how to use the stochatic optimization
+This example is designed to show how to use the stochastic optimization
algorithms for discrete and semi-continuous measures from the POT library.
[18] Genevay, A., Cuturi, M., Peyré, G. & Bach, F.
@@ -61,7 +61,7 @@ print(sag_pi)
# Semi-Continuous Case
# ````````````````````
#
-# Sample one general measure a, one discrete measures b for the semicontinous
+# Sample one general measure a, one discrete measures b for the semicontinuous
# case, the points where source and target measures are defined and compute the
# cost matrix.
@@ -80,7 +80,7 @@ Y_target = rng.randn(n_target, 2)
M = ot.dist(X_source, Y_target)
#############################################################################
-# Call the "ASGD" method to find the transportation matrix in the semicontinous
+# Call the "ASGD" method to find the transportation matrix in the semicontinuous
# case.
method = "ASGD"
diff --git a/examples/plot_Intro_OT.py b/examples/plot_Intro_OT.py
index 219aa51..1c51360 100644
--- a/examples/plot_Intro_OT.py
+++ b/examples/plot_Intro_OT.py
@@ -67,7 +67,7 @@ help(ot.dist)
# We extracted from this search their positions and generated fictional
# production and sale number (that both sum to the same value).
#
-# We have acess to the position of Bakeries ``bakery_pos`` and their
+# We have access to the position of Bakeries ``bakery_pos`` and their
# respective production ``bakery_prod`` which describe the source
# distribution. The Cafés where the croissants are sold are defined also by
# their position ``cafe_pos`` and ``cafe_prod``, and describe the target
@@ -166,10 +166,10 @@ time_emd = time.time() - start
# The function returns the transport matrix, which we can then visualize (next section).
##############################################################################
-# Transportation plan vizualization
+# Transportation plan visualization
# `````````````````````````````````
#
-# A good vizualization of the OT matrix in the 2D plane is to denote the
+# A good visualization of the OT matrix in the 2D plane is to denote the
# transportation of mass between a Bakery and a Café by a line. This can easily
# be done with a double ``for`` loop.
#
diff --git a/examples/plot_OT_1D_smooth.py b/examples/plot_OT_1D_smooth.py
index ff51b8a..626938c 100644
--- a/examples/plot_OT_1D_smooth.py
+++ b/examples/plot_OT_1D_smooth.py
@@ -94,6 +94,6 @@ max_nz = 2 # two non-zero entries are permitted per column of the OT plan
Gsc = ot.smooth.smooth_ot_dual(
a, b, M, lambd, reg_type='sparsity_constrained', max_nz=max_nz)
pl.figure(5, figsize=(5, 5))
-ot.plot.plot1D_mat(a, b, Gsc, 'Sparsity contrained OT matrix; k=2.')
+ot.plot.plot1D_mat(a, b, Gsc, 'Sparsity constrained OT matrix; k=2.')
pl.show()
diff --git a/examples/plot_OT_2D_samples.py b/examples/plot_OT_2D_samples.py
index 1d82fb8..4b98892 100644
--- a/examples/plot_OT_2D_samples.py
+++ b/examples/plot_OT_2D_samples.py
@@ -4,8 +4,8 @@
Optimal Transport between 2D empirical distributions
====================================================
-Illustration of 2D optimal transport between discributions that are weighted
-sum of diracs. The OT matrix is plotted with the samples.
+Illustration of 2D optimal transport between distributions that are weighted
+sum of Diracs. The OT matrix is plotted with the samples.
"""
@@ -105,7 +105,7 @@ pl.show()
##############################################################################
-# Emprirical Sinkhorn
+# Empirical Sinkhorn
# -------------------
#%% sinkhorn
diff --git a/examples/plot_OT_L1_vs_L2.py b/examples/plot_OT_L1_vs_L2.py
index 7a08197..e1d102c 100644
--- a/examples/plot_OT_L1_vs_L2.py
+++ b/examples/plot_OT_L1_vs_L2.py
@@ -4,7 +4,7 @@
Optimal Transport with different ground metrics
================================================
-2D OT on empirical distributio with different ground metric.
+2D OT on empirical distribution with different ground metric.
Stole the figure idea from Fig. 1 and 2 in
https://arxiv.org/pdf/1706.07650.pdf
diff --git a/examples/plot_compute_emd.py b/examples/plot_compute_emd.py
index 36cc7da..32d63e8 100644
--- a/examples/plot_compute_emd.py
+++ b/examples/plot_compute_emd.py
@@ -4,7 +4,7 @@
OT distances in 1D
==================
-Shows how to compute multiple Wassersein and Sinkhorn with two different
+Shows how to compute multiple Wasserstein and Sinkhorn with two different
ground metrics and plot their values for different distributions.
@@ -76,7 +76,7 @@ pl.tight_layout()
#%% Compute and plot distributions and loss matrix
d_emd = ot.emd2(a, B, M) # direct computation of OT loss
-d_emd2 = ot.emd2(a, B, M2) # direct computation of OT loss with metrixc M2
+d_emd2 = ot.emd2(a, B, M2) # direct computation of OT loss with metric M2
d_tv = [np.sum(abs(a - B[:, i])) for i in range(n_target)]
pl.figure(2)
diff --git a/examples/sliced-wasserstein/plot_variance.py b/examples/sliced-wasserstein/plot_variance.py
index f12b522..2293247 100644
--- a/examples/sliced-wasserstein/plot_variance.py
+++ b/examples/sliced-wasserstein/plot_variance.py
@@ -83,6 +83,6 @@ pl.xscale('log')
pl.xlabel("Number of projections")
pl.ylabel("Distance")
-pl.title('Sliced Wasserstein Distance with 95% confidence inverval')
+pl.title('Sliced Wasserstein Distance with 95% confidence interval')
pl.show()
diff --git a/examples/sliced-wasserstein/plot_variance_ssw.py b/examples/sliced-wasserstein/plot_variance_ssw.py
index 83d458f..f5fc35f 100644
--- a/examples/sliced-wasserstein/plot_variance_ssw.py
+++ b/examples/sliced-wasserstein/plot_variance_ssw.py
@@ -106,6 +106,6 @@ pl.xscale('log')
pl.xlabel("Number of projections")
pl.ylabel("Distance")
-pl.title('Spherical Sliced Wasserstein Distance with 95% confidence inverval')
+pl.title('Spherical Sliced Wasserstein Distance with 95% confidence interval')
pl.show()
diff --git a/examples/unbalanced-partial/plot_UOT_barycenter_1D.py b/examples/unbalanced-partial/plot_UOT_barycenter_1D.py
index 8d227c0..f747055 100644
--- a/examples/unbalanced-partial/plot_UOT_barycenter_1D.py
+++ b/examples/unbalanced-partial/plot_UOT_barycenter_1D.py
@@ -4,7 +4,7 @@
1D Wasserstein barycenter demo for Unbalanced distributions
===========================================================
-This example illustrates the computation of regularized Wassersyein Barycenter
+This example illustrates the computation of regularized Wasserstein Barycenter
as proposed in [10] for Unbalanced inputs.
diff --git a/examples/unbalanced-partial/plot_regpath.py b/examples/unbalanced-partial/plot_regpath.py
index 782e8c2..d1f2042 100644
--- a/examples/unbalanced-partial/plot_regpath.py
+++ b/examples/unbalanced-partial/plot_regpath.py
@@ -60,7 +60,7 @@ pl.show()
##############################################################################
# Compute semi-relaxed and fully relaxed regularization paths
-# -----------
+# -----------------------------------------------------------
#%%
final_gamma = 1e-8
@@ -72,9 +72,9 @@ t2, t_list2, g_list2 = ot.regpath.regularization_path(a, b, M, reg=final_gamma,
##############################################################################
# Plot the regularization path
-# ----------------
+# ----------------------------
#
-# The OT plan is ploted as a function of $\gamma$ that is the inverse of the
+# The OT plan is plotted as a function of $\gamma$ that is the inverse of the
# weight on the marginal relaxations.
#%% fully relaxed l2-penalized UOT
@@ -109,7 +109,7 @@ pl.show()
# %%
# Animation of the regpath for UOT l2
-# ------------------------
+# -----------------------------------
nv = 100
g_list_v = np.logspace(-.5, -2.5, nv)
@@ -149,7 +149,7 @@ ani = animation.FuncAnimation(pl.gcf(), _update_plot, nv, interval=50, repeat_de
##############################################################################
# Plot the semi-relaxed regularization path
-# -------------------
+# -----------------------------------------
#%% semi-relaxed l2-penalized UOT
@@ -181,7 +181,7 @@ pl.show()
# %%
# Animation of the regpath for semi-relaxed UOT l2
-# ------------------------
+# ------------------------------------------------
nv = 100
g_list_v = np.logspace(2.5, -2, nv)