From 062071b20d1d40c64bb619931bd11bd28e780485 Mon Sep 17 00:00:00 2001 From: RĂ©mi Flamary Date: Fri, 1 Sep 2017 15:31:44 +0200 Subject: update example with rst titles --- docs/source/auto_examples/plot_WDA.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'docs/source/auto_examples/plot_WDA.py') diff --git a/docs/source/auto_examples/plot_WDA.py b/docs/source/auto_examples/plot_WDA.py index 42789f2..06a2e38 100644 --- a/docs/source/auto_examples/plot_WDA.py +++ b/docs/source/auto_examples/plot_WDA.py @@ -4,6 +4,12 @@ Wasserstein Discriminant Analysis ================================= +This example illustrate the use of WDA as proposed in [11]. + + +[11] Flamary, R., Cuturi, M., Courty, N., & Rakotomamonjy, A. (2016). +Wasserstein Discriminant Analysis. + """ # Author: Remi Flamary @@ -16,6 +22,10 @@ import matplotlib.pylab as pl from ot.dr import wda, fda +############################################################################## +# Generate data +############################################################################## + #%% parameters n = 1000 # nb samples in source and target datasets @@ -39,6 +49,10 @@ nbnoise = 8 xs = np.hstack((xs, np.random.randn(n, nbnoise))) xt = np.hstack((xt, np.random.randn(n, nbnoise))) +############################################################################## +# Plot data +############################################################################## + #%% plot samples pl.figure(1, figsize=(6.4, 3.5)) @@ -53,11 +67,19 @@ pl.legend(loc=0) pl.title('Other dimensions') pl.tight_layout() +############################################################################## +# Compute Fisher Discriminant Analysis +############################################################################## + #%% Compute FDA p = 2 Pfda, projfda = fda(xs, ys, p) +############################################################################## +# Compute Wasserstein Discriminant Analysis +############################################################################## + #%% Compute WDA p = 2 reg = 1e0 @@ -66,6 +88,11 @@ maxiter = 100 Pwda, projwda = wda(xs, ys, p, reg, k, maxiter=maxiter) + +############################################################################## +# Plot 2D projections +############################################################################## + #%% plot samples xsp = projfda(xs) -- cgit v1.2.3