summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorLaetitia Chapel <laetitia.chapel@univ-ubs.fr>2020-04-20 13:50:14 +0200
committerLaetitia Chapel <laetitia.chapel@univ-ubs.fr>2020-04-20 13:50:14 +0200
commitfcf23770c5ed5252dee233b578239118d9d8ba62 (patch)
tree313b0b792eb8f2f24ebd0b4c318f2fdb1706d9e1 /examples
parentde5679ad6e284c7d8751bcef05d4be5fd79d0aec (diff)
doc kwargs + fix rst issues
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/plot_partial_wass_and_gromov.py24
1 files changed, 11 insertions, 13 deletions
diff --git a/examples/plot_partial_wass_and_gromov.py b/examples/plot_partial_wass_and_gromov.py
index 30b3fc0..a5af441 100755
--- a/examples/plot_partial_wass_and_gromov.py
+++ b/examples/plot_partial_wass_and_gromov.py
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
"""
-==========================
+==================================================
Partial Wasserstein and Gromov-Wasserstein example
-==========================
+==================================================
This example is designed to show how to use the Partial (Gromov-)Wassertsein
distance computation in POT.
@@ -50,8 +50,7 @@ pl.show()
#############################################################################
#
-# Compute partial Wasserstein plans and distance,
-# by transporting 50% of the mass
+# Compute partial Wasserstein plans and distance
# ----------------------------------------------
p = ot.unif(n_samples + n_noise)
@@ -113,34 +112,33 @@ pl.show()
#############################################################################
#
-# Compute partial Gromov-Wasserstein plans and distance,
-# by transporting 100% and 2/3 of the mass
+# Compute partial Gromov-Wasserstein plans and distance
# -----------------------------------------------------
C1 = sp.spatial.distance.cdist(xs, xs)
C2 = sp.spatial.distance.cdist(xt, xt)
+# transport 100% of the mass
print('-----m = 1')
m = 1
-res0, log0 = ot.partial.partial_gromov_wasserstein(C1, C2, p, q, m=m,
- log=True)
+res0, log0 = ot.partial.partial_gromov_wasserstein(C1, C2, p, q, m=m, log=True)
res, log = ot.partial.entropic_partial_gromov_wasserstein(C1, C2, p, q, 10,
m=m, log=True)
-print('Partial Wasserstein distance (m = 1): ' + str(log0['partial_gw_dist']))
-print('Entropic partial Wasserstein distance (m = 1): ' +
- str(log['partial_gw_dist']))
+print('Wasserstein distance (m = 1): ' + str(log0['partial_gw_dist']))
+print('Entropic Wasserstein distance (m = 1): ' + str(log['partial_gw_dist']))
pl.figure(1, (10, 5))
pl.title("mass to be transported m = 1")
pl.subplot(1, 2, 1)
pl.imshow(res0, cmap='jet')
-pl.title('Partial Wasserstein')
+pl.title('Wasserstein')
pl.subplot(1, 2, 2)
pl.imshow(res, cmap='jet')
-pl.title('Entropic partial Wasserstein')
+pl.title('Entropic Wasserstein')
pl.show()
+# transport 2/3 of the mass
print('-----m = 2/3')
m = 2 / 3
res0, log0 = ot.partial.partial_gromov_wasserstein(C1, C2, p, q, m=m, log=True)