Skip to content

[MRG] Partial ot: doc kwargs + fix rst issues #142

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 2 commits into from
Apr 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions examples/plot_partial_wass_and_gromov.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -50,8 +50,7 @@

#############################################################################
#
# 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)
Expand Down Expand Up @@ -113,34 +112,33 @@

#############################################################################
#
# 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)
Expand Down
6 changes: 6 additions & 0 deletions ot/partial.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ def partial_wasserstein_lagrange(a, b, M, reg_m=None, nb_dummies=1, log=False,
instabilities, increase its value if an error is raised)
log : bool, optional
record log if True
**kwargs : dict
parameters can be directly passed to the emd solver

.. warning::
When dealing with a large number of points, the EMD solver may face
Expand Down Expand Up @@ -190,6 +192,8 @@ def partial_wasserstein(a, b, M, m=None, nb_dummies=1, log=False, **kwargs):
instabilities, increase its value if an error is raised)
log : bool, optional
record log if True
**kwargs : dict
parameters can be directly passed to the emd solver


.. warning::
Expand Down Expand Up @@ -304,6 +308,8 @@ def partial_wasserstein2(a, b, M, m=None, nb_dummies=1, log=False, **kwargs):
instabilities, increase its value if an error is raised)
log : bool, optional
record log if True
**kwargs : dict
parameters can be directly passed to the emd solver


.. warning::
Expand Down