# source:orange/Orange/testing/regression/tests_20/reference_examplesdistance-missing.py@9952:986e9cd806f4

Revision 9952:986e9cd806f4, 1.2 KB checked in by Miha Stajdohar <miha.stajdohar@…>, 2 years ago (diff)

Tests moved and renamed from orange 20.

Line
1# Description: Shows how to construct and use classes for measuring distances between examples
2# Category:    distances
3# Classes:     ExamplesDistanceConstructor, ExamplesDistance
4# Uses:        lenses
5# Referenced:  ExamplesDistance.htm
6
7
8import orange
9
10data = orange.ExampleTable("iris")
11distance = orange.ExamplesDistanceConstructor_Euclidean(data)
12
13ref = data[0]
14refm = orange.Example(ref)
15refm[0] = "?"
16
17print "d(%s, %s) = %5.3f" % (ref, ref, distance(ref, ref))
18print "d(%s, %s)   = %5.3f" % (ref, refm, distance(ref, refm))
19print "d(%s,   %s)   = %5.3f" % (refm, refm, distance(refm, refm))
20print
21
22ref = data[50]
23refm = orange.Example(ref)
24refm[0] = "?"
25print "d(%s, %s) = %5.3f" % (ref, ref, distance(ref, ref))
26print "d(%s, %s)   = %5.3f" % (ref, refm, distance(ref, refm))
27print "d(%s,   %s)   = %5.3f" % (refm, refm, distance(refm, refm))
28print
29
30data = orange.ExampleTable("lenses")
31distance = orange.ExamplesDistanceConstructor_Euclidean(data)
32
33ref = data[0]
34refm = orange.Example(ref)
35refm[0] = "?"
36
37print "d(%s, %s) = %5.3f" % (ref, ref, distance(ref, ref))
38print "d(%s, %s)   = %5.3f" % (ref, refm, distance(ref, refm))
39print "d(%s,   %s)   = %5.3f" % (refm, refm, distance(refm, refm))
40print
Note: See TracBrowser for help on using the repository browser.