source: orange/docs/reference/rst/code/distances-test.py @ 9823:7f9c3f3c6474

Revision 9823:7f9c3f3c6474, 553 bytes checked in by lanumek, 2 years ago (diff)

Changed names of data sets (table replaced with data or name of the data set).

Line 
1import Orange
2
3# Read some data
4iris = Orange.data.Table("iris.tab")
5
6# Euclidean distance constructor
7d2Constr = Orange.distance.instances.EuclideanConstructor()
8d2 = d2Constr(iris)
9
10# Constructs
11dPears = Orange.distance.instances.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.