source: orange/docs/reference/rst/code/distances-test.py @ 9372:aef193695ea9

Revision 9372:aef193695ea9, 559 bytes checked in by mitar, 2 years ago (diff)

Moved documentation to the separate directory.

Line 
1import Orange
2
3# Read some data
4table = Orange.data.Table("iris.tab")
5
6# Euclidean distance constructor
7d2Constr = Orange.distance.instances.EuclideanConstructor()
8d2 = d2Constr(table)
9
10# Constructs
11dPears = Orange.distance.instances.PearsonRConstructor(table)
12
13#reference instance
14ref = table[0]
15
16print "Euclidean distances from the first data instance: "
17
18for ins in table[:5]:
19    print "%5.4f" % d2(ins, ref),
20print 
21
22print "Pearson correlation distance from the first data instance: "
23
24for ins in table[:5]:
25    print "%5.4f" % dPears(ins, ref),
26print 
Note: See TracBrowser for help on using the repository browser.