source: orange/orange/doc/Orange/rst/code/kmeans-cmp-init.py @ 7130:12a00963a5e8

Revision 7130:12a00963a5e8, 699 bytes checked in by markotoplak, 3 years ago (diff)

Added Makefile for doc/Orange.

Line 
1import orange
2import Orange.cluster
3import random
4
5data_names = ["iris", "housing", "vehicle"]
6data_sets = [orange.ExampleTable(name) for name in data_names]
7
8print "%10s %3s %3s %3s" % ("", "Rnd", "Div", "HC")
9for data, name in zip(data_sets, data_names):
10    random.seed(42)
11    km_random = Orange.cluster.KMeans(data, centroids = 3)
12    km_diversity = Orange.cluster.KMeans(data, centroids = 3, \
13        initialization=Orange.cluster.kmeans_init_diversity)
14    km_hc = Orange.cluster.KMeans(data, centroids = 3, \
15        initialization=Orange.cluster.KMeans_init_hierarchicalClustering(n=100))
16    print "%10s %3d %3d %3d" % (name, km_random.iteration, km_diversity.iteration, km_hc.iteration)
Note: See TracBrowser for help on using the repository browser.