@@ -3,14 +3,10 @@ Welcome to python-cluster's documentation!
33
44Implementation of cluster algorithms in pure Python.
55
6- .. warning ::
76
8- This is currently a bug in HierarchicalClustering which causes incorrect
9- output. This is currently being worked on. In the meantime
10- ``HierarchicalClustering `` should be regarded as *broken *!
117
12- Example
13- -------
8+ Example for K-Means Clustering
9+ ------------------------------
1410
1511::
1612
@@ -30,7 +26,7 @@ Example
3026 (9, 3)
3127 ]
3228 cl = KMeansClustering(data)
33- c .getclusters(2)
29+ cl .getclusters(2)
3430
3531The above code would give the following result::
3632
@@ -39,6 +35,44 @@ The above code would give the following result::
3935 [(3, 5), (1, 5), (3, 4), (2, 6), (2, 5), (3, 6)]
4036 ]
4137
38+
39+ Example for Hierarchical Clustering
40+ -----------------------------------
41+
42+ ::
43+
44+ from cluster import HierarchicalClustering
45+ data = [791, 956, 676, 124, 564, 84, 24, 365, 594, 940, 398,
46+ 971, 131, 365, 542, 336, 518, 835, 134, 391]
47+ cl = HierarchicalClustering(data)
48+ cl.getlevel(40)
49+
50+ The above code would give the following result::
51+
52+ [
53+ [24],
54+ [84, 124, 131, 134],
55+ [336, 365, 365, 391, 398],
56+ [676],
57+ [594, 518, 542, 564],
58+ [940, 956, 971],
59+ [791],
60+ [835],
61+ ]
62+
63+
64+ Using :py:meth: `~cluster.method.hierarchical.HierarchicalClustering.getlevel() `
65+ returns clusters where the distance between each cluster is no less than
66+ *level *.
67+
68+ .. note ::
69+
70+ Due to a bug _ in earlier releases, the elements of the input data *must be *
71+ sortable!
72+
73+ .. _bug : https://github.com/exhuma/python-cluster/issues/11
74+
75+
4276API
4377---
4478
0 commit comments