diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/plot_OT_1D.py | 2 | ||||
-rw-r--r-- | examples/plot_OT_2D_samples.py | 5 | ||||
-rw-r--r-- | examples/plot_barycenter_1D.py | 4 | ||||
-rw-r--r-- | examples/plot_barycenter_lp_vs_entropic.py | 29 | ||||
-rw-r--r-- | examples/plot_compute_emd.py | 2 | ||||
-rw-r--r-- | examples/plot_gromov.py | 2 | ||||
-rw-r--r-- | examples/plot_optim_OTreg.py | 4 | ||||
-rw-r--r-- | examples/plot_otda_classes.py | 6 | ||||
-rw-r--r-- | examples/plot_otda_d2.py | 4 | ||||
-rw-r--r-- | examples/plot_otda_linear_mapping.py | 10 | ||||
-rw-r--r-- | examples/plot_otda_mapping.py | 6 | ||||
-rw-r--r-- | examples/plot_otda_semi_supervised.py | 4 |
12 files changed, 37 insertions, 41 deletions
diff --git a/examples/plot_OT_1D.py b/examples/plot_OT_1D.py index 90325c9..f33e2a4 100644 --- a/examples/plot_OT_1D.py +++ b/examples/plot_OT_1D.py @@ -17,7 +17,7 @@ import numpy as np import matplotlib.pylab as pl import ot import ot.plot -from ot.datasets import get_1D_gauss as gauss +from ot.datasets import make_1D_gauss as gauss ############################################################################## # Generate data diff --git a/examples/plot_OT_2D_samples.py b/examples/plot_OT_2D_samples.py index 9818ec5..bb952a0 100644 --- a/examples/plot_OT_2D_samples.py +++ b/examples/plot_OT_2D_samples.py @@ -16,6 +16,7 @@ sum of diracs. The OT matrix is plotted with the samples. import numpy as np import matplotlib.pylab as pl import ot +import ot.plot ############################################################################## # Generate data @@ -31,8 +32,8 @@ cov_s = np.array([[1, 0], [0, 1]]) mu_t = np.array([4, 4]) cov_t = np.array([[1, -.8], [-.8, 1]]) -xs = ot.datasets.get_2D_samples_gauss(n, mu_s, cov_s) -xt = ot.datasets.get_2D_samples_gauss(n, mu_t, cov_t) +xs = ot.datasets.make_2D_samples_gauss(n, mu_s, cov_s) +xt = ot.datasets.make_2D_samples_gauss(n, mu_t, cov_t) a, b = np.ones((n,)) / n, np.ones((n,)) / n # uniform distribution on samples diff --git a/examples/plot_barycenter_1D.py b/examples/plot_barycenter_1D.py index ecf640c..5ed9f3f 100644 --- a/examples/plot_barycenter_1D.py +++ b/examples/plot_barycenter_1D.py @@ -37,8 +37,8 @@ n = 100 # nb bins x = np.arange(n, dtype=np.float64) # Gaussian distributions -a1 = ot.datasets.get_1D_gauss(n, m=20, s=5) # m= mean, s= std -a2 = ot.datasets.get_1D_gauss(n, m=60, s=8) +a1 = ot.datasets.make_1D_gauss(n, m=20, s=5) # m= mean, s= std +a2 = ot.datasets.make_1D_gauss(n, m=60, s=8) # creating matrix A containing all distributions A = np.vstack((a1, a2)).T diff --git a/examples/plot_barycenter_lp_vs_entropic.py b/examples/plot_barycenter_lp_vs_entropic.py index 6936bbb..b82765e 100644 --- a/examples/plot_barycenter_lp_vs_entropic.py +++ b/examples/plot_barycenter_lp_vs_entropic.py @@ -15,8 +15,6 @@ Wasserstein problems. SIAM Journal on Imaging Sciences, 9(1), 320-343. Iterative Bregman projections for regularized transportation problems SIAM Journal on Scientific Computing, 37(2), A1111-A1138. - - """ # Author: Remi Flamary <remi.flamary@unice.fr> @@ -32,8 +30,8 @@ from matplotlib.collections import PolyCollection # noqa #import ot.lp.cvx as cvx -# -# Generate data +############################################################################## +# Gaussian Data # ------------- #%% parameters @@ -47,8 +45,8 @@ x = np.arange(n, dtype=np.float64) # Gaussian distributions # Gaussian distributions -a1 = ot.datasets.get_1D_gauss(n, m=20, s=5) # m= mean, s= std -a2 = ot.datasets.get_1D_gauss(n, m=60, s=8) +a1 = ot.datasets.make_1D_gauss(n, m=20, s=5) # m= mean, s= std +a2 = ot.datasets.make_1D_gauss(n, m=60, s=8) # creating matrix A containing all distributions A = np.vstack((a1, a2)).T @@ -58,9 +56,6 @@ n_distributions = A.shape[1] M = ot.utils.dist0(n) M /= M.max() -# -# Plot data -# --------- #%% plot the distributions @@ -70,10 +65,6 @@ for i in range(n_distributions): pl.title('Distributions') pl.tight_layout() -# -# Barycenter computation -# ---------------------- - #%% barycenter computation alpha = 0.5 # 0<=alpha<=1 @@ -110,6 +101,10 @@ pl.tight_layout() problems.append([A, [bary_l2, bary_wass, bary_wass2]]) +############################################################################## +# Dirac Data +# ---------- + #%% parameters a1 = 1.0 * (x > 10) * (x < 50) @@ -135,9 +130,6 @@ for i in range(n_distributions): pl.title('Distributions') pl.tight_layout() -# -# Barycenter computation -# ---------------------- #%% barycenter computation @@ -207,9 +199,6 @@ for i in range(n_distributions): pl.title('Distributions') pl.tight_layout() -# -# Barycenter computation -# ---------------------- #%% barycenter computation @@ -249,7 +238,7 @@ pl.title('Barycenters') pl.tight_layout() -# +############################################################################## # Final figure # ------------ # diff --git a/examples/plot_compute_emd.py b/examples/plot_compute_emd.py index 73b42c3..7ed2b01 100644 --- a/examples/plot_compute_emd.py +++ b/examples/plot_compute_emd.py @@ -17,7 +17,7 @@ ground metrics and plot their values for diffeent distributions. import numpy as np import matplotlib.pylab as pl import ot -from ot.datasets import get_1D_gauss as gauss +from ot.datasets import make_1D_gauss as gauss ############################################################################## diff --git a/examples/plot_gromov.py b/examples/plot_gromov.py index 5cd40f6..deb2f86 100644 --- a/examples/plot_gromov.py +++ b/examples/plot_gromov.py @@ -38,7 +38,7 @@ mu_t = np.array([4, 4, 4]) cov_t = np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]])
-xs = ot.datasets.get_2D_samples_gauss(n_samples, mu_s, cov_s)
+xs = ot.datasets.make_2D_samples_gauss(n_samples, mu_s, cov_s)
P = sp.linalg.sqrtm(cov_t)
xt = np.random.randn(n_samples, 3).dot(P) + mu_t
diff --git a/examples/plot_optim_OTreg.py b/examples/plot_optim_OTreg.py index 92df016..2c58def 100644 --- a/examples/plot_optim_OTreg.py +++ b/examples/plot_optim_OTreg.py @@ -42,8 +42,8 @@ n = 100 # nb bins x = np.arange(n, dtype=np.float64) # Gaussian distributions -a = ot.datasets.get_1D_gauss(n, m=20, s=5) # m= mean, s= std -b = ot.datasets.get_1D_gauss(n, m=60, s=10) +a = ot.datasets.make_1D_gauss(n, m=20, s=5) # m= mean, s= std +b = ot.datasets.make_1D_gauss(n, m=60, s=10) # loss matrix M = ot.dist(x.reshape((n, 1)), x.reshape((n, 1))) diff --git a/examples/plot_otda_classes.py b/examples/plot_otda_classes.py index b14c11a..c311fbd 100644 --- a/examples/plot_otda_classes.py +++ b/examples/plot_otda_classes.py @@ -25,8 +25,8 @@ import ot n_source_samples = 150 n_target_samples = 150 -Xs, ys = ot.datasets.get_data_classif('3gauss', n_source_samples) -Xt, yt = ot.datasets.get_data_classif('3gauss2', n_target_samples) +Xs, ys = ot.datasets.make_data_classif('3gauss', n_source_samples) +Xt, yt = ot.datasets.make_data_classif('3gauss2', n_target_samples) ############################################################################## @@ -82,7 +82,7 @@ pl.tight_layout() # Fig 2 : plot optimal couplings and transported samples # ------------------------------------------------------ -param_img = {'interpolation': 'nearest', 'cmap': 'spectral'} +param_img = {'interpolation': 'nearest'} pl.figure(2, figsize=(15, 8)) pl.subplot(2, 4, 1) diff --git a/examples/plot_otda_d2.py b/examples/plot_otda_d2.py index 70beb35..cf22c2f 100644 --- a/examples/plot_otda_d2.py +++ b/examples/plot_otda_d2.py @@ -29,8 +29,8 @@ import ot.plot n_samples_source = 150 n_samples_target = 150 -Xs, ys = ot.datasets.get_data_classif('3gauss', n_samples_source) -Xt, yt = ot.datasets.get_data_classif('3gauss2', n_samples_target) +Xs, ys = ot.datasets.make_data_classif('3gauss', n_samples_source) +Xt, yt = ot.datasets.make_data_classif('3gauss2', n_samples_target) # Cost matrix M = ot.dist(Xs, Xt, metric='sqeuclidean') diff --git a/examples/plot_otda_linear_mapping.py b/examples/plot_otda_linear_mapping.py index 7a3b761..c65bd4f 100644 --- a/examples/plot_otda_linear_mapping.py +++ b/examples/plot_otda_linear_mapping.py @@ -1,11 +1,17 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- """ -Created on Tue Mar 20 14:31:15 2018 +============================ +Linear OT mapping estimation +============================ + -@author: rflamary """ +# Author: Remi Flamary <remi.flamary@unice.fr> +# +# License: MIT License + import numpy as np import pylab as pl import ot diff --git a/examples/plot_otda_mapping.py b/examples/plot_otda_mapping.py index 167c3a1..5880adf 100644 --- a/examples/plot_otda_mapping.py +++ b/examples/plot_otda_mapping.py @@ -32,11 +32,11 @@ n_target_samples = 100 theta = 2 * np.pi / 20 noise_level = 0.1 -Xs, ys = ot.datasets.get_data_classif( +Xs, ys = ot.datasets.make_data_classif( 'gaussrot', n_source_samples, nz=noise_level) -Xs_new, _ = ot.datasets.get_data_classif( +Xs_new, _ = ot.datasets.make_data_classif( 'gaussrot', n_source_samples, nz=noise_level) -Xt, yt = ot.datasets.get_data_classif( +Xt, yt = ot.datasets.make_data_classif( 'gaussrot', n_target_samples, theta=theta, nz=noise_level) # one of the target mode changes its variance (no linear mapping) diff --git a/examples/plot_otda_semi_supervised.py b/examples/plot_otda_semi_supervised.py index 7963aef..8a67720 100644 --- a/examples/plot_otda_semi_supervised.py +++ b/examples/plot_otda_semi_supervised.py @@ -29,8 +29,8 @@ import ot n_samples_source = 150 n_samples_target = 150 -Xs, ys = ot.datasets.get_data_classif('3gauss', n_samples_source) -Xt, yt = ot.datasets.get_data_classif('3gauss2', n_samples_target) +Xs, ys = ot.datasets.make_data_classif('3gauss', n_samples_source) +Xt, yt = ot.datasets.make_data_classif('3gauss2', n_samples_target) ############################################################################## |