Skip to content

btaba/sinkhorn_knopp

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

About

python implementation of Sinkhorn-Knopp

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages