Skip to content

Commit fab20da

Browse files
committed
update readme
1 parent 132d547 commit fab20da

File tree

3 files changed

+80
-8
lines changed

3 files changed

+80
-8
lines changed

README.md

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,42 @@ obviously you need CUDA installed and a compatible GPU.
7272

7373
## Examples
7474

75-
The examples folder contain several examples and use case for the library. The full documentation is available on [Readthedocs](http://pot.readthedocs.io/)
75+
### Short examples
7676

77-
Here is a list of the Python notebooks if you want a quick look:
77+
* Import the toolbox
78+
```python
79+
import ot
80+
```
81+
* Compute Wasserstein distances
82+
```python
83+
# a,b are 1D histograms (sum to 1 and positive)
84+
# M is the ground cost matrix
85+
Wd=ot.emd2(a,b,M) # exact linear program
86+
# if b is a matrix compute all distances to a and return a vector
87+
```
88+
* Compute OT matrix
89+
```python
90+
# a,b are 1D histograms (sum to 1 and positive)
91+
# M is the ground cost matrix
92+
Totp=ot.emd(a,b,M) # exact linear program
93+
Totp_reg=ot.sinkhorn(a,b,M,reg) # entropic regularized OT
94+
```
95+
* Compute Wasserstein barycenter
96+
```python
97+
# A is a n*d matrix containing d 1D histograms
98+
# M is the ground cost matrix
99+
ba=ot.barycenter(A,M,reg) # reg is regularization parameter
100+
```
101+
102+
103+
104+
105+
### Examples and Notebooks
106+
107+
The examples folder contain several examples and use case for the library. The full documentation is available on [Readthedocs](http://pot.readthedocs.io/).
108+
109+
110+
Here is a list of the Python notebooks available [here](https://github.com/rflamary/POT/blob/master/notebooks/) if you want a quick look:
78111

79112
* [1D optimal transport](https://github.com/rflamary/POT/blob/master/notebooks/Demo_1D_OT.ipynb)
80113
* [OT Ground Loss](https://github.com/rflamary/POT/blob/master/notebooks/Demo_Ground_Loss.ipynb)
@@ -88,8 +121,7 @@ The examples folder contain several examples and use case for the library. The f
88121
* [OT mapping estimation for color transfer in images](https://github.com/rflamary/POT/blob/master/notebooks/Demo_Image_ColorAdaptation_mapping.ipynb)
89122
* [Wasserstein Discriminant Analysis](https://github.com/rflamary/POT/blob/master/notebooks/Demo_Wasserstein_Discriminant_Analysis.ipynb)
90123

91-
92-
You can also see the notebooks with [Jupyter nbviewer](https://nbviewer.jupyter.org/github/rflamary/POT/tree/master/examples/).
124+
You can also see the notebooks with [Jupyter nbviewer](https://nbviewer.jupyter.org/github/rflamary/POT/tree/master/notebooks/).
93125

94126
## Acknowledgements
95127

docs/source/readme.rst

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,51 @@ obviously you need CUDA installed and a compatible GPU.
9393
Examples
9494
--------
9595

96+
Short examples
97+
~~~~~~~~~~~~~~
98+
99+
- Import the toolbox
100+
101+
.. code:: python
102+
103+
import ot
104+
105+
- Compute Wasserstein distances
106+
107+
.. code:: python
108+
109+
# a,b are 1D histograms (sum to 1 and positive)
110+
# M is the ground cost matrix
111+
Wd=ot.emd2(a,b,M) # exact linear program
112+
# if b is a matrix compute all distances to a and return a vector
113+
114+
- Compute OT matrix
115+
116+
.. code:: python
117+
118+
# a,b are 1D histograms (sum to 1 and positive)
119+
# M is the ground cost matrix
120+
Totp=ot.emd(a,b,M) # exact linear program
121+
Totp_reg=ot.sinkhorn(a,b,M,reg) # entropic regularized OT
122+
123+
- Compute Wasserstein barycenter
124+
125+
.. code:: python
126+
127+
# A is a n*d matrix containing d 1D histograms
128+
# M is the ground cost matrix
129+
ba=ot.barycenter(A,M,reg) # reg is regularization parameter
130+
131+
Examples and Notebooks
132+
~~~~~~~~~~~~~~~~~~~~~~
133+
96134
The examples folder contain several examples and use case for the
97135
library. The full documentation is available on
98-
`Readthedocs <http://pot.readthedocs.io/>`__
136+
`Readthedocs <http://pot.readthedocs.io/>`__.
99137

100-
Here is a list of the Python notebooks if you want a quick look:
138+
Here is a list of the Python notebooks available
139+
`here <https://github.com/rflamary/POT/blob/master/notebooks/>`__ if you
140+
want a quick look:
101141

102142
- `1D optimal
103143
transport <https://github.com/rflamary/POT/blob/master/notebooks/Demo_1D_OT.ipynb>`__
@@ -123,7 +163,7 @@ Here is a list of the Python notebooks if you want a quick look:
123163
Analysis <https://github.com/rflamary/POT/blob/master/notebooks/Demo_Wasserstein_Discriminant_Analysis.ipynb>`__
124164

125165
You can also see the notebooks with `Jupyter
126-
nbviewer <https://nbviewer.jupyter.org/github/rflamary/POT/tree/master/examples/>`__.
166+
nbviewer <https://nbviewer.jupyter.org/github/rflamary/POT/tree/master/notebooks/>`__.
127167

128168
Acknowledgements
129169
----------------

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
ROOT = os.path.abspath(os.path.dirname(__file__))
2222

2323

24-
# convert markdown readme to rst in pypandoc installed
24+
# convert markdown readme to rst if pypandoc installed
2525
try:
2626
import pypandoc
2727
README = pypandoc.convert('README.md', 'rst')

0 commit comments

Comments
 (0)