source: orange/docs/tutorial/rst/code/domain4.py @ 9374:59bac7ddd8a2

Revision 9374:59bac7ddd8a2, 674 bytes checked in by mitar, 2 years ago (diff)

Tutorial documentation structure.

Line 
1# Description: Shows how to select examples based on their attribute values
2# Category:    preprocessing
3# Uses:        imports-85
4# Referenced:  domain.htm
5
6import orange
7
8def report_prob(header, data):
9  print 'Size of %s: %i instances' % (header, len(data))
10  n = 0
11  for i in data:
12    if int(i.getclass())==0:
13      n = n + 1
14  print "p(%s)=%5.3f" % (data.domain.classVar.values[0], float(n)/len(data))
15
16filename = "../../datasets/adult_sample.tab"
17data = orange.ExampleTable(filename)
18report_prob('original data set', data)
19
20data1 = data.select(sex='Male')
21report_prob('data1', data1)
22
23data2 = data.select(sex='Male', education='Masters')
24report_prob('data2', data2)
25
Note: See TracBrowser for help on using the repository browser.