source: orange/orange/doc/Orange/rst/code/kmeans-cmp-init.py @ 7743:5277d8c12ca8

Revision 7743:5277d8c12ca8, 708 bytes checked in by lanz <lan.zagar@…>, 3 years ago (diff)

Corrected the (broken) example scripts for kmeans.

Line 
1import random
2import Orange
3
4data_names = ["iris", "housing", "vehicle"]
5data_sets = [Orange.data.Table(name) for name in data_names]
6
7print "%10s %3s %3s %3s" % ("", "Rnd", "Div", "HC")
8for data, name in zip(data_sets, data_names):
9    random.seed(42)
10    km_random = Orange.clustering.kmeans.Clustering(data, centroids = 3)
11    km_diversity = Orange.clustering.kmeans.Clustering(data, centroids = 3,
12        initialization=Orange.clustering.kmeans.init_diversity)
13    km_hc = Orange.clustering.kmeans.Clustering(data, centroids = 3,
14        initialization=Orange.clustering.kmeans.init_hclustering(n=100))
15    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.