summaryrefslogtreecommitdiff
path: root/docs/source/auto_examples/plot_WDA.ipynb
diff options
context:
space:
mode:
authorRémi Flamary <remi.flamary@gmail.com>2017-06-09 13:57:07 +0200
committerRémi Flamary <remi.flamary@gmail.com>2017-06-09 13:57:07 +0200
commit05da582675c89ab20998e1a9505bf3c220e296b8 (patch)
treede91f6ac74e8bab182e5f54a4b9d8b5b0a58991d /docs/source/auto_examples/plot_WDA.ipynb
parentc7a5e3290527c372aa203c18df5f054409e8a60c (diff)
update doc
Diffstat (limited to 'docs/source/auto_examples/plot_WDA.ipynb')
-rw-r--r--docs/source/auto_examples/plot_WDA.ipynb54
1 files changed, 54 insertions, 0 deletions
diff --git a/docs/source/auto_examples/plot_WDA.ipynb b/docs/source/auto_examples/plot_WDA.ipynb
new file mode 100644
index 0000000..6d641a7
--- /dev/null
+++ b/docs/source/auto_examples/plot_WDA.ipynb
@@ -0,0 +1,54 @@
+{
+ "nbformat_minor": 0,
+ "nbformat": 4,
+ "cells": [
+ {
+ "execution_count": null,
+ "cell_type": "code",
+ "source": [
+ "%matplotlib inline"
+ ],
+ "outputs": [],
+ "metadata": {
+ "collapsed": false
+ }
+ },
+ {
+ "source": [
+ "\n# WAsserstein Discriminant Analysis\n\n\n@author: rflamary\n\n"
+ ],
+ "cell_type": "markdown",
+ "metadata": {}
+ },
+ {
+ "execution_count": null,
+ "cell_type": "code",
+ "source": [
+ "import numpy as np\nimport matplotlib.pylab as pl\nimport ot\nfrom ot.datasets import get_1D_gauss as gauss\nfrom ot.dr import wda\n\n\n#%% parameters\n\nn=1000 # nb samples in source and target datasets\nnz=0.2\nxs,ys=ot.datasets.get_data_classif('3gauss',n,nz)\nxt,yt=ot.datasets.get_data_classif('3gauss',n,nz)\n\nnbnoise=8\n\nxs=np.hstack((xs,np.random.randn(n,nbnoise)))\nxt=np.hstack((xt,np.random.randn(n,nbnoise)))\n\n#%% plot samples\n\npl.figure(1)\n\n\npl.scatter(xt[:,0],xt[:,1],c=ys,marker='+',label='Source samples')\npl.legend(loc=0)\npl.title('Discriminant dimensions')\n\n\n#%% plot distributions and loss matrix\np=2\nreg=1\nk=10\nmaxiter=100\n\nP,proj = wda(xs,ys,p,reg,k,maxiter=maxiter)\n\n#%% plot samples\n\nxsp=proj(xs)\nxtp=proj(xt)\n\npl.figure(1,(10,5))\n\npl.subplot(1,2,1)\npl.scatter(xsp[:,0],xsp[:,1],c=ys,marker='+',label='Projected samples')\npl.legend(loc=0)\npl.title('Projected training samples')\n\n\npl.subplot(1,2,2)\npl.scatter(xtp[:,0],xtp[:,1],c=ys,marker='+',label='Projected samples')\npl.legend(loc=0)\npl.title('Projected test samples')"
+ ],
+ "outputs": [],
+ "metadata": {
+ "collapsed": false
+ }
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 2",
+ "name": "python2",
+ "language": "python"
+ },
+ "language_info": {
+ "mimetype": "text/x-python",
+ "nbconvert_exporter": "python",
+ "name": "python",
+ "file_extension": ".py",
+ "version": "2.7.12",
+ "pygments_lexer": "ipython2",
+ "codemirror_mode": {
+ "version": 2,
+ "name": "ipython"
+ }
+ }
+ }
+} \ No newline at end of file