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

Revision 526:fe2d65da2b2a, 937 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 use ExampleTable.select and ExampleTable.getitems for sampling
2# Category:    basic classes, sampling
3# Classes:     ExampleTable, MakeRandomIndices, MakeRandomIndicesCV
4# Uses:       
5# Referenced:  ExampleTable.htm
6
7import orange
8
9domain = orange.Domain([orange.FloatVariable()])
10data = orange.ExampleTable(domain)
11for i in range(10):
12    data.append([i])
13
14for d in data:
15    print d,
16print "\n"
17
18cv_indices = orange.MakeRandomIndicesCV(data, 4)
19print "Indices: ", cv_indices, "\n"
20
21for fold in range(4):
22    train = data.select(cv_indices, fold, negate = 1)
23    test  = data.select(cv_indices, fold)
24    print "Fold %d: train " % fold
25    for ex in train:
26        print "    ", ex
27    print
28    print "      : test  "
29    for ex in test:
30        print "    ", ex
31    print
32
33t = data.select([1, 1, 0, 0, 0,  0, 0, 0, 0, 1])
34for ex in t:
35    print ex
36
37e = data.getitems([0, 1, 9])
38for ex in e:
39    print ex
Note: See TracBrowser for help on using the repository browser.