source: orange/docs/reference/rst/code/distances-test.py @ 9663:74b63c8ea80c

Revision 9663:74b63c8ea80c, 533 bytes checked in by markotoplak, 2 years ago (diff)

Orange.distance.instances -> Orange.distance

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