Package: ot-markov-distances
Differentiable distances on graphs based on optimal transportThis is the implementation code forBrugere, T., Wan, Z., & Wang, Y. (2023). Distances for Markov Chains, and Their Differentiation. ArXiv, abs/2302.08621.SetupInstalling as a libraryTheot_markov_distancespackage can be installed with the following command:pip install ot-markov-distancesIf for some reason you need to usecuda11.8(ie you are installingtorch+cuda118)
then use the following command insteadpip install git+https://github.com/YusuLab/ot_markov_distances@cuda118DependenciesPython versionThis project requirespython 3.10a minima.
If your python version is prior to3.10,
you need to update (or to create a newcondaenvironment)
to a version above (latest release at the time of writing is3.12)Python dependenciesNoteThe main branch uses the default (cuda12) version of torch
in its dependencies. If for some
reason you need to usecuda11.8, clone thecuda118branch
insteadThis package manages its dependencies viapoetry. I recommend you install it
(otherwise if you prefer to manage them manually, a list of the
dependencies is available in the filepyproject.toml)When you havepoetry, you can add dependencies using our makefileNoteIf you want to create a virtual environment for this project
(as opposed to using the one you are currently in)
you can use the commandpoetry env use python3.12(or other python version)$make.make/depsor directly with poetry$poetryinstallTUDatasetIf you are planning to reproduce the classification experiment.TheTUDatasetpackage is also needed to run the classification experiment,
but it is not available viapip/poetry.
To install it, follow the instruction inthe tudataset repo,
including the “Compilation of kernel baselines” section, and add the directory where you downloaded it to your$PYTHONPATH.
eg:$exportPYTHONPATH="/path/to/tudataset:$PYTHONPATH"Project structure.
├── docs    #contains the generated docs (after typing make)
│   ├── build
│   │   └── html            #Contains the html docs in readthedocs format
│   └── source
├── experiments             #contains jupyter notebooks with the experiments
│   └── utils               #contains helper code for the experiments
├── ot_markov_distances     #contains reusable library code for computing and differentiating the discounted WL distance
│   ├── discounted_wl.py    # implementation of our discounted WL distance
│   ├── __init__.py
│   ├── sinkhorn.py         # implementation of the sinkhorn distance
│   ├── utils.py            # utility functions
│   └── wl.py               #implementation of the wl distance by Chen et al.
├── staticdocs #contains the static source for the docs
│   ├── build
│   └── source
└── tests #contains sanity checksDocumentationThe documentation is available online:read the documentationWarningDo not edit the documentation directly in thedocs/folder,
that folder is wiped every time the documentation is built. The
static parts of the documentation can be edited instaticdocs/.You can build documentation and run tests using$makeAlternatively, you can build only the documentation using$make.make/build-docsThe documentation will be available indocs/build/htmlin the
readthedocs formatRunning ExperimentsRunning experiments requires installing development dependencies. This can be done by running$make.make/dev-depsor alternatively$poetryinstall--withdevExperimentscan be found in theexperiments/directory (seeProject structure).The Barycenter and Coarsening experiments can be found inexperiments/Barycenter.ipynbandexperiments/Coarsening.ipynb.The performance graphs are computed inexperiments/Performance.ipynbClassification experimentThe Classification experiment (see the first paragraph of section 6 in the paper) is not in a jupyter notebook, but accessible via a command line.As an additional dependency it needstudataset, which is not installable viapip. To install it follow the instructions inthe tudataset repo.
, including the “Compilation of kernel baselines” section, and add the directory where you downloaded it to your$PYTHONPATH.Now you can run the classification experiment using the command$poetryrunpython-mexperiments.classificationusage: python -m experiments.classification [-h] {datasets_info,distances,eval} ...

Run classification experiments on graph datasets

positional arguments:
  {datasets_info,distances,eval}
    datasets_info       Print information about given datasets
    distances           Compute distance matrices for given datasets
    eval                Evaluate a kernel based on distance matrix

options:
  -h, --help            show this help message and exitThe yaml file containing dataset information that should be passed to the command line is inexperiments/grakel_datasets.yaml.
Modifying this file should allow running the experiment on different datasets.FAQI have a question about the paperIn this case just send me an email through the email address mentioned in the paper.I have noticed a bug in the codePlease use the Github “Issues” feature to open a ticket, and post a description of the bug, the error message and aminimal reproducible example. I’ll try to fix it.Or if you have fixed it, you can submit a Pull Request directlyI cannot install the libraryIf you followed all the instructions correctly, please create a ticket using Github Issues.Why do you needpython3.10?Because I am usingstructural pattern matching, and some typing features such asthis one.