source: orange/orange/doc/reference/findnearest.py @ 526:fe2d65da2b2a

Revision 526:fe2d65da2b2a, 729 bytes checked in by janezd <janez.demsar@…>, 10 years ago (diff)
  • moved documentation from a separate module to this one
Line 
1# Description: Shows how to find the nearest neighbours of the given example
2# Category:    basic classes, distances
3# Classes:     FindNearest, FindNearestConstructor, FindNearest_BruteForce, FindNearestConstructor_BruteForce
4# Uses:        lenses
5# Referenced:  FindNearest.htm
6
7
8import orange
9
10data = orange.ExampleTable("lenses")
11
12nnc = orange.FindNearestConstructor_BruteForce()
13nnc.distanceConstructor = orange.ExamplesDistanceConstructor_Euclidean()
14
15did = -42
16# Note that this is wrong: id should be assigned by
17# did = orange.newmetaid()
18# We only do this so that the script gives the same output each time it's run
19nn = nnc(data, 0, did)
20
21print "*** Reference example: ", data[0]
22for ex in nn(data[0], 5):
23    print ex
Note: See TracBrowser for help on using the repository browser.