diff options
author | Rémi Flamary <remi.flamary@gmail.com> | 2016-10-31 11:29:36 +0100 |
---|---|---|
committer | Rémi Flamary <remi.flamary@gmail.com> | 2016-10-31 11:29:36 +0100 |
commit | e3b115001ccde177d5d73e4f9dd0f52ed964371d (patch) | |
tree | 61e9fdfef16fe061eff107d25d91c88d74f3d464 | |
parent | d3d8689b9230ea6066409ff44969817da6f5af50 (diff) | |
parent | 475810754e05bb64ce27264d0a7e533355e07dff (diff) |
Merge branch 'master' into DA
-rw-r--r-- | MANIFEST.in | 7 | ||||
-rw-r--r-- | Makefile | 5 | ||||
-rw-r--r-- | README.md | 36 | ||||
-rw-r--r-- | docs/source/conf.py | 10 | ||||
-rw-r--r-- | docs/source/index.rst | 5 | ||||
-rw-r--r-- | ot/__init__.py | 2 | ||||
-rw-r--r-- | setup.cfg | 2 | ||||
-rwxr-xr-x | setup.py | 30 |
8 files changed, 79 insertions, 18 deletions
diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..8c14549 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,7 @@ +graft ot/lp/ +include README.md +include ot/lp/core.h +include ot/lp/EMD.h +include ot/lp/emd.pyx +include ot/lp/full_bipartitegraph.h +include ot/lp/network_simplex_simple.h @@ -33,6 +33,11 @@ sremove : clean : $(PYTHON) setup.py clean + +uploadpypi: + python setup.py register + python setup.py sdist upload -r pypi + notebook : ipython notebook --matplotlib=inline --notebook-dir=examples/ @@ -1,14 +1,24 @@ # POT: Python Optimal Transport + +[![Documentation Status](https://readthedocs.org/projects/pot/badge/?version=latest)](http://pot.readthedocs.io/en/latest/?badge=latest) + This open source Python library provide several solvers for optimization problems related to Optimal Transport for signal, image processing and machine learning. It provides the following solvers: + * OT solver for the linear program/ Earth Movers Distance [1]. * Entropic regularization OT solver with Sinkhorn Knopp Algorithm [2]. * Bregman projections for Wasserstein barycenter [3] and unmixing [4]. * Optimal transport for domain adaptation with group lasso regularization [5] * Conditional gradient [6] and Generalized conditional gradient for regularized OT [7]. +We are also currently working on the following features: + +- [ ] Image color adaptation demo +- [ ] Scikit-learn inspired classes for domain adaptation +- [ ] Mapping estimation as proposed in [8] + Some demonstrations (both in Python and Jupyter Notebook format) are available in the examples folder. ## Installation @@ -17,13 +27,24 @@ The Library has been tested on Linux and MacOSX. It requires a C++ compiler for - Numpy (>=1.11) - Scipy (>=0.17) +- Cython (>=0.23) +- Matplotlib (>=1.5) + + +Under debian based linux the dependencies can be installed with +``` +sudo apt-get install python-numpy python-scipy python-matplotlib cython +``` To install the library, you can install it locally (after downloading it) on you machine using ``` python setup.py install --user ``` - +The toolbox is also available on PyPI with a possibly slightly older version. You can install it with: +``` +pip install POT +``` After a correct installation, you should be able to import the module without errors: ```python @@ -34,19 +55,20 @@ Note that for easier access the module is name ot instead of pot. ## Examples -The examples folder contain several examples and use case for the library. +The examples folder contain several examples and use case for the library. The full documentation is available on [Readthedoc](http://pot.readthedocs.io/) Here is a list of the Python notebook if you want a quick look: -* [1D optimal transport](examples/Demo_1D_OT.ipynb) -* [2D optimal transport on empirical distributions](examples/Demo_2D_OT_samples.ipynb) -* [1D Wasserstein barycenter](examples/Demo_1D_barycenter.ipynb) -* [OT with user provided regularization](examples/Demo_Optim_OTreg.ipynb) +* [1D optimal transport](https://github.com/rflamary/POT/blob/master/examples/Demo_1D_OT.ipynb) +* [2D optimal transport on empirical distributions](https://github.com/rflamary/POT/blob/master/examples/Demo_2D_OT_samples.ipynb) +* [1D Wasserstein barycenter](https://github.com/rflamary/POT/blob/master/examples/Demo_1D_barycenter.ipynb) +* [OT with user provided regularization](https://github.com/rflamary/POT/blob/master/examples/Demo_Optim_OTreg.ipynb) ## Acknowledgements The contributors to this library are: + * [Rémi Flamary](http://remi.flamary.com/) * [Nicolas Courty](http://people.irisa.fr/Nicolas.Courty/) * [Laetitia Chapel](http://people.irisa.fr/Laetitia.Chapel/) @@ -73,3 +95,5 @@ This toolbox benefit a lot from open source research and we would like to thank [6] Ferradans, S., Papadakis, N., Peyré, G., & Aujol, J. F. (2014). Regularized discrete optimal transport. SIAM Journal on Imaging Sciences, 7(3), 1853-1882. [7] Rakotomamonjy, A., Flamary, R., & Courty, N. (2015). Generalized conditional gradient: analysis of convergence and applications. arXiv preprint arXiv:1510.06567. + +[8] M. Perrot, N. Courty, R. Flamary, A. Habrard, "Mapping estimation for discrete optimal transport", Neural Information Processing Systems (NIPS), 2016. diff --git a/docs/source/conf.py b/docs/source/conf.py index 1c1bb40..b56df38 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -14,9 +14,19 @@ import sys import os +from unittest.mock import MagicMock sys.path.insert(0, os.path.abspath("../..")) + +class Mock(MagicMock): + @classmethod + def __getattr__(cls, name): + return Mock() + +MOCK_MODULES = [ 'emd','ot.lp.emd'] +sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES) + # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. diff --git a/docs/source/index.rst b/docs/source/index.rst index 8452f00..adbabb6 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -30,11 +30,6 @@ Contents all examples -Examples --------- - - - References ---------- diff --git a/ot/__init__.py b/ot/__init__.py index 72c820a..cf55711 100644 --- a/ot/__init__.py +++ b/ot/__init__.py @@ -17,5 +17,7 @@ from .da import sinkhorn_lpl1_mm # utils functions from .utils import dist, unif +__version__ = "0.1.6" + __all__ = ["emd", "sinkhorn", "utils", 'datasets', 'bregman', 'lp', 'plot', 'dist', 'unif', 'barycenter', 'sinkhorn_lpl1_mm', 'da', 'optim'] diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..b88034e --- /dev/null +++ b/setup.cfg @@ -0,0 +1,2 @@ +[metadata] +description-file = README.md @@ -3,25 +3,39 @@ from setuptools import setup, find_packages from codecs import open from os import path -import numpy from setuptools.extension import Extension from Cython.Build import cythonize - +import numpy +import re +import os here = path.abspath(path.dirname(__file__)) -import os + #import glob -version='0.1' +# dirty but working +__version__ = re.search( + r'__version__\s*=\s*[\'"]([^\'"]*)[\'"]', # It excludes inline comment too + open('ot/__init__.py').read()).group(1) +# The beautiful part is, I don't even need to check exceptions here. +# If something messes up, let the build process fail noisy, BEFORE my release! ROOT = os.path.abspath(os.path.dirname(__file__)) -README = open(os.path.join(ROOT, 'README.md')).read() + + +# convert markdown readme to rst in pypandoc installed +try: + import pypandoc + README = pypandoc.convert('README.md', 'rst') +except (IOError, ImportError): + README = open(os.path.join(ROOT, 'README.md')).read() + setup(name='POT', - version=version, + version=__version__, description='Python Optimal Transport Library', long_description=README, author=u'Remi Flamary, Nicolas Courty', @@ -35,10 +49,12 @@ setup(name='POT', language="c++", # generate and compile C++ code, include_dirs=[numpy.get_include(),os.path.join(ROOT,'ot/lp')])), platforms=['linux','macosx','windows'], + download_url='https://github.com/rflamary/POT/archive/V{}.tar.gz'.format(__version__), license = 'MIT', scripts=[], data_files=[], - requires=["numpy (>=1.11)","scipy (>=0.17)"], + requires=["numpy (>=1.11)","scipy (>=0.17)","cython (>=0.23)","matplotlib (>=1.5)"], + install_requires=["numpy (>=1.11)","scipy (>=0.17)","cython (>=0.23)","matplotlib (>=1.5)"], classifiers=[ 'Development Status :: 4 - Beta', 'Intended Audience :: Developers', |