Ignore:
Timestamp:
03/15/11 14:57:05 (3 years ago)
Author:
lanz <lan.zagar@…>
Branch:
default
Convert:
a4d5dd3bc47b1cea11932b6f17ec5c28b3b34b4c
Message:

Corrected the (broken) example scripts for kmeans.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orange/doc/Orange/rst/code/kmeans-cmp-init.py

    r7130 r7743  
    1 import orange 
    2 import Orange.cluster 
    31import random 
     2import Orange 
    43 
    54data_names = ["iris", "housing", "vehicle"] 
    6 data_sets = [orange.ExampleTable(name) for name in data_names] 
     5data_sets = [Orange.data.Table(name) for name in data_names] 
    76 
    87print "%10s %3s %3s %3s" % ("", "Rnd", "Div", "HC") 
    98for data, name in zip(data_sets, data_names): 
    109    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)) 
     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)) 
    1615    print "%10s %3d %3d %3d" % (name, km_random.iteration, km_diversity.iteration, km_hc.iteration) 
Note: See TracChangeset for help on using the changeset viewer.