source: orange/docs/reference/rst/code/som-mapping.py @ 10322:9d9d8963f195

Revision 10322:9d9d8963f195, 604 bytes checked in by Ales Erjavec <ales.erjavec@…>, 2 years ago (diff)

Set random seed in som-mapping.py example (so results are reproducible).

Line 
1# Description: Self Organizing Maps on iris data set
2# Category:    projection
3# Uses:        iris
4# Referenced:  Orange.projection.som
5# Classes:     Orange.projection.som.SOMLearner
6
7import Orange
8
9import random
10random.seed(0)
11
12som = Orange.projection.som.SOMLearner(map_shape=(3, 3),
13                initialize=Orange.projection.som.InitializeRandom)
14map = som(Orange.data.Table("iris.tab"))
15
16print "Node    Instances"
17print "\n".join(["%s  %d" % (str(n.pos), len(n.examples)) for n in map])
18
19i, j = 1, 2
20print
21print "Data instances in cell (%d, %d):" % (i, j)
22for e in map[i, j].examples:
23    print e
Note: See TracBrowser for help on using the repository browser.