a hierachical clustering algorithm based on information theory
Project description
Python binding
How to build
The binding uses boost-python library. To enable it, run cmake
with -DUSE_PYTHON=ON
To make it independent of boost dynamic library, static linking should be enabled in CMAKE configuration.
To package the library, use python setup.py bdist_wheel
.
Install the package by pip install --user info_cluster
. If your system cmake is called cmake3, you can use
CMAKE=cmake3 pip install --user info_cluster`.
Below is the prebuild
binary packages:
Platform | py3.6 | py3.7 |
---|---|---|
Windows | T | T |
MacOS | T | T |
Linux |
Demo code
We provide a high-level wrapper of info-clustering algorithm.
After installing info_cluster
, you can use it as follows:
from info_cluster import InfoCluster
import networkx as nx
g = nx.Graph() # undirected graph
g.add_edge(0, 1, weight=1)
g.add_edge(1, 2, weight=1)
g.add_edge(0, 2, weight=5)
ic = InfoCluster(affinity='precomputed') # use precomputed graph structure
ic.fit(g)
ic.print_hierachical_tree()
The output is like
/-0
/-|
--| \-2
|
\-1
import psp # classify the three data points shown in the above figure
g = psp.PyGraph(3, [(0,1,1),(1,2,1),(0,2,5)]) # index started from zero, similarity is 5 for vertex 0 and 2
g.run() # use maximal flow algorithm to classify them
print(g.get_critical_values()) # [2,5]
print(g.get_category(2)) # get the result which has at least 2 categories, which is [0,1,0]
Parametric Dilworth Truncation(pdt) implementation
We provide another alternative implementation, which can be used similar to PyGraph.
To make it work, you should apply a patch preflow.patch to preflow.h
before building, which belongs to lemon library 1.3.1, see
#625.
import psp
g = psp.PyGraphPDT(3, [(0,1,1),(1,2,1),(0,2,5)]) # index started from zero, similarity is 5 for vertex 0 and 2
g.run() # use maximal flow algorithm to classify them
print(g.get_critical_values()) # [2,5]
print(g.get_category(2)) # get the result which has at least 2 categories, which is [0,1,0]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Hashes for info_cluster-0.4.post2-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1b0a5bbfc6b10ed5db33ab4fcdbeb0ba6a47c3fa91bad235dcc0b313f72205a |
|
MD5 | 0393062749f5ac04da7483ea2b6f5503 |
|
BLAKE2b-256 | 7283de18607afbe15afbeeff67964222f5594a14db6ea81b4fbe2efea3da3636 |
Hashes for info_cluster-0.4.post2-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 473c77c6437cb59a96f368658a359d15360d3b03a8d1a47513551e42bab2c9c1 |
|
MD5 | caf5c77794041c241a1f7bccc7167db5 |
|
BLAKE2b-256 | 3dbd3d0668179fccaf05677ba32a3ea1b3f59ae9a20fe45b4b51e9cf96863e87 |
Hashes for info_cluster-0.4.post2-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f8b4e838c5ac81fdd2f23b53e57bf141920a84e3ca84e16b9173f178cf20dc7e |
|
MD5 | b08dce0a2bbe1fbd7ea31be5500c208c |
|
BLAKE2b-256 | f58bb73f9f1a9de267615eb240351bf3e56af04a0cef89e7edaf68560f45798a |
Hashes for info_cluster-0.4.post2-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3c62bd096f14f2813f4b571900f8ac6854b42be0a1652e87d07729c810ef881c |
|
MD5 | af82a81e46bf96637d5cd26d1ddd7cb0 |
|
BLAKE2b-256 | c982dbd6d35029ddb109a4b8ec41ef280785a849b9bc9986afd72fa2ca2c63df |
Hashes for info_cluster-0.4.post2-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59b16aa9c0a591be964f2dc0770c2f391a47e79cb50d1c1b14d1ad886848f8d0 |
|
MD5 | 9e8eb5729860cf5ab2c45d68f84e0ede |
|
BLAKE2b-256 | 7f3fbafcbf101599bf8690fb930ba7a6acdf91e5680331ca1f6b7e8687ab9e35 |
Hashes for info_cluster-0.4.post2-cp36-cp36m-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f3c9962c14596b531f6992d116887d3c3458754d3e8445ed55bb3cb8e1634c56 |
|
MD5 | 4f64304391ba69a3264d3ddc6d52fb08 |
|
BLAKE2b-256 | b5e67cfbd2e6d17dff90513fbe4c7426739c257ecdb1eeeda5fd7545cb0d3cc1 |