diff options
author | Slasnista <stan.chambon@gmail.com> | 2017-08-29 09:05:01 +0200 |
---|---|---|
committer | Slasnista <stan.chambon@gmail.com> | 2017-08-29 09:05:01 +0200 |
commit | a29e22db4772ebc4a8266c917e2e662f624c6baa (patch) | |
tree | 352a04e3e01ffbb0696403f9af4857758ed86342 /examples | |
parent | 7d3fc95abe059cc7404f3c213dfd5019cf110737 (diff) |
addressed AG comments + adding random seed
Diffstat (limited to 'examples')
-rw-r--r-- | examples/da/plot_otda_classes.py | 2 | ||||
-rw-r--r-- | examples/da/plot_otda_color_images.py | 3 | ||||
-rw-r--r-- | examples/da/plot_otda_d2.py | 14 | ||||
-rw-r--r-- | examples/da/plot_otda_mapping.py | 14 | ||||
-rw-r--r-- | examples/da/plot_otda_mapping_colors_images.py | 2 |
5 files changed, 21 insertions, 14 deletions
diff --git a/examples/da/plot_otda_classes.py b/examples/da/plot_otda_classes.py index e5c82fb..6870fa4 100644 --- a/examples/da/plot_otda_classes.py +++ b/examples/da/plot_otda_classes.py @@ -15,8 +15,10 @@ approaches currently supported in POT. # License: MIT License import matplotlib.pylab as pl +import numpy as np import ot +np.random.seed(42) # number of source and target points to generate ns = 150 diff --git a/examples/da/plot_otda_color_images.py b/examples/da/plot_otda_color_images.py index bca7350..805d0b0 100644 --- a/examples/da/plot_otda_color_images.py +++ b/examples/da/plot_otda_color_images.py @@ -20,9 +20,10 @@ SIAM Journal on Imaging Sciences, 7(3), 1853-1882. import numpy as np from scipy import ndimage import matplotlib.pylab as pl - import ot +np.random.seed(42) + def im2mat(I): """Converts and image to matrix (one pixel per line)""" diff --git a/examples/da/plot_otda_d2.py b/examples/da/plot_otda_d2.py index 1d2192f..8833eb2 100644 --- a/examples/da/plot_otda_d2.py +++ b/examples/da/plot_otda_d2.py @@ -19,17 +19,19 @@ of what the transport methods are doing. # License: MIT License import matplotlib.pylab as pl +import numpy as np import ot -# number of source and target points to generate -ns = 150 -nt = 150 +np.random.seed(42) -Xs, ys = ot.datasets.get_data_classif('3gauss', ns) -Xt, yt = ot.datasets.get_data_classif('3gauss2', nt) +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) # Cost matrix -M = ot.dist(Xs, Xt) +M = ot.dist(Xs, Xt, metric='sqeuclidean') # Instantiate the different transport algorithms and fit them diff --git a/examples/da/plot_otda_mapping.py b/examples/da/plot_otda_mapping.py index 6d83507..aea7f09 100644 --- a/examples/da/plot_otda_mapping.py +++ b/examples/da/plot_otda_mapping.py @@ -23,7 +23,7 @@ import matplotlib.pylab as pl import ot -np.random.seed(0) +np.random.seed(42) ############################################################################## # generate @@ -31,10 +31,11 @@ np.random.seed(0) n = 100 # nb samples in source and target datasets theta = 2 * np.pi / 20 -nz = 0.1 -Xs, ys = ot.datasets.get_data_classif('gaussrot', n, nz=nz) -Xs_new, _ = ot.datasets.get_data_classif('gaussrot', n, nz=nz) -Xt, yt = ot.datasets.get_data_classif('gaussrot', n, theta=theta, nz=nz) +noise_level = 0.1 +Xs, ys = ot.datasets.get_data_classif('gaussrot', n, nz=noise_level) +Xs_new, _ = ot.datasets.get_data_classif('gaussrot', n, nz=noise_level) +Xt, yt = ot.datasets.get_data_classif( + 'gaussrot', n, theta=theta, nz=noise_level) # one of the target mode changes its variance (no linear mapping) Xt[yt == 2] *= 3 @@ -46,8 +47,7 @@ ot_mapping_linear = ot.da.MappingTransport( kernel="linear", mu=1e0, eta=1e-8, bias=True, max_iter=20, verbose=True) -ot_mapping_linear.fit( - Xs=Xs, Xt=Xt) +ot_mapping_linear.fit(Xs=Xs, Xt=Xt) # for original source samples, transform applies barycentric mapping transp_Xs_linear = ot_mapping_linear.transform(Xs=Xs) diff --git a/examples/da/plot_otda_mapping_colors_images.py b/examples/da/plot_otda_mapping_colors_images.py index 4209020..6c024ea 100644 --- a/examples/da/plot_otda_mapping_colors_images.py +++ b/examples/da/plot_otda_mapping_colors_images.py @@ -23,6 +23,8 @@ from scipy import ndimage import matplotlib.pylab as pl import ot +np.random.seed(42) + def im2mat(I): """Converts and image to matrix (one pixel per line)""" |