Skip to content

Commit fae41b3

Browse files
committed
Added an example for KMeansClustering.
1 parent 2c85401 commit fae41b3

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

docs/index.rst

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,46 @@
11
Welcome to python-cluster's documentation!
22
==========================================
33

4-
API Docs:
4+
Implementation of cluster algorithms in pure Python.
5+
6+
.. warning::
7+
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*!
11+
12+
Example
13+
-------
14+
15+
::
16+
17+
from cluster import KMeansClustering
18+
data = [
19+
(8, 2),
20+
(7, 3),
21+
(2, 6),
22+
(3, 5),
23+
(3, 6),
24+
(1, 5),
25+
(8, 1),
26+
(3, 4),
27+
(8, 3),
28+
(9, 2),
29+
(2, 5),
30+
(9, 3)
31+
]
32+
cl = KMeansClustering(data)
33+
c.getclusters(2)
34+
35+
The above code would give the following result::
36+
37+
[
38+
[(8, 2), (8, 1), (8, 3), (7, 3), (9, 2), (9, 3)],
39+
[(3, 5), (1, 5), (3, 4), (2, 6), (2, 5), (3, 6)]
40+
]
41+
42+
API
43+
---
544

645
.. toctree::
746
:maxdepth: 1

0 commit comments

Comments
 (0)