a hierachical clustering algorithm based on information theory
Project description
Python binding
How to build
The binding uses Cython
.
To package the library, use python setup.py bdist_wheel
.
Install the package by pip install --user info_cluster
.
Below is the prebuilt binary packages:
Platform | py3.6 | py3.7 |
---|---|---|
Windows | T | T |
MacOS | T | T |
Linux | T | T |
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_hierarchical_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]
ChangeLog
- Version 0.2: expose
PSP
(C++) class, which is high customizable in python. - Version 0.3: expose
PyGraphPDT
(C++) class, which has similar API asPyGraph
but different inner implementation. - Version 0.5: expose
run_psp_i
for
InfoCluster`
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
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distributions
Close
Hashes for info_cluster-0.6-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | caee6476aea5a9da0fa0b872d1e91a117676c12fe68af8ce06d502946ebe9d1d |
|
MD5 | 3fd7def952731a4984f3ee72e35c1a6a |
|
BLAKE2b-256 | 60e91aa43ca77e949f93c963d302d55cedd4d6d9c26df6a0db2ea0186f62d132 |
Close
Hashes for info_cluster-0.6-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 590af887f7145ad6ae93d1d8d4bb5271c3919da6538eea6ab5d2f26cc08d9a15 |
|
MD5 | c88bab6b04762cb46de1b7c1ded71fa0 |
|
BLAKE2b-256 | bfdb9911d0d9b60d98f6b1aab381f175fd8402745fc49d450c08679bcf82f180 |
Close
Hashes for info_cluster-0.6-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 960cadffc221784ead8ef2dcaeb00d9a0ab2a2aaf4a8be6858d0211124f68a08 |
|
MD5 | 0f7e177c5f2657187b0c1f96b70e5bff |
|
BLAKE2b-256 | 6f449b31b846808d0628355a6c1d8fc8ab884e220b46bfe8d48ddea13fef186d |
Close
Hashes for info_cluster-0.6-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0120970ea596d8f880428177f962722984cf264bded87c2f04c548ed08f2ef1f |
|
MD5 | c8afc12e7531c839e10d9f3f7a811cf3 |
|
BLAKE2b-256 | bb95cd5b2d2699af68b0ffc9712c061aed7dd728d1b5236926f2df7d75be81ac |
Close
Hashes for info_cluster-0.6-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 28fa068ad24f44e54a75350475dc3d71606d0b81bd69e418a40c6746afb17682 |
|
MD5 | 34c365abebce5adefb6790446bcfed49 |
|
BLAKE2b-256 | ab31f36cda13812f9132a4e122ffae909fcae22a23f2651af5ff73fd4ebcc771 |