python implementation of Sinkhorn-Knopp
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
sinkhorn_knopp
tests
.gitignore
.travis.yml
LICENSE.txt
MANIFEST.in
README.md
setup.cfg
setup.py

README.md

sinkhorn_knopp

Build Status

To convert non-negative square matrices with total support into doubly stochastic matrices.

    >> import numpy as np
    >> from sinkhorn_knopp import sinkhorn_knopp as skp
    >> sk = skp.SinkhornKnopp()
    >> P = [[.011, .15], [1.71, .1]]
    >> P_ds = sk.fit(P)
    >> print P_ds
        [[ 0.06102561  0.93897439]
        [ 0.93809928  0.06190072]]
    >> print np.sum(P_ds, axis=0)
        [ 0.99912489  1.00087511]
    >> print np.sum(P_ds, axis=1)
        [ 1.,  1.]

See http://msp.org/pjm/1967/21-2/pjm-v21-n2-p14-s.pdf for reference.

Install

Either:

pip install sinkhorn_knopp

or

git clone https://github.com/btaba/sinkhorn_knopp
cd sinkhorn_knopp
python setup.py install

Uninstall

Depending on the above, either:

pip uninstall sinkhorn_knopp

or

cd sinkhorn_knopp
python setup.py install --record files.txt
cat files.txt | xargs rm -rf