Skip to content

Commit 8e1a9a9

Browse files
committed
Documentation updated.
1 parent dc9f779 commit 8e1a9a9

File tree

2 files changed

+42
-8
lines changed

2 files changed

+42
-8
lines changed

cluster/method/hierarchical.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class HierarchicalClustering(BaseClusterMethod):
3131
Implementation of the hierarchical clustering method as explained in a
3232
tutorial_ by *matteucc*.
3333
34-
.. _tutorial:: http://www.elet.polimi.it/upload/matteucc/Clustering/tutorial_html/hierarchical.html
34+
.. _tutorial: http://www.elet.polimi.it/upload/matteucc/Clustering/tutorial_html/hierarchical.html
3535
3636
Example:
3737

docs/index.rst

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,10 @@ Welcome to python-cluster's documentation!
33

44
Implementation 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

3531
The 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+
4276
API
4377
---
4478

0 commit comments

Comments
 (0)