source: orange/docs/reference/rst/code/datatable2.py @ 9927:d6ca7b346864

Revision 9927:d6ca7b346864, 927 bytes checked in by markotoplak, 2 years ago (diff)

data.variable -> feature.

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.data.Domain([Orange.feature.Continuous()])
10data = Orange.data.Table(domain)
11for i in range(10):
12    data.append([i])
13
14cv_indices = Orange.core.MakeRandomIndicesCV(data, 4)
15print "Indices: ", cv_indices, "\n"
16
17for fold in range(4):
18    train = data.select(cv_indices, fold, negate = 1)
19    test  = data.select(cv_indices, fold)
20    print "Fold %d: train " % fold
21    for inst in train:
22        print "    ", inst
23    print
24    print "      : test  "
25    for inst in test:
26        print "    ", inst
27    print
28
29t = data.select([1, 1, 0, 0, 0,  0, 0, 0, 0, 1])
30for inst in t:
31    print inst
32
33e = data.get_items([0, 1, 9])
34for inst in e:
35    print inst
Note: See TracBrowser for help on using the repository browser.