source: orange/orange/doc/reference/examplesdistance-missing.py @ 608:943314f03748

Revision 608:943314f03748, 1.2 KB checked in by janezd <janez.demsar@…>, 10 years ago (diff)
  • ExamplesDistance_Euclidean now correctly treats unknown values
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.