source: orange/docs/tutorial/rst/code/domain4.py @ 9746:f2ff17dfd86e

Revision 9746:f2ff17dfd86e, 663 bytes checked in by Miha Stajdohar <miha.stajdohar@…>, 2 years ago (diff)

Changed data set path.

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 = "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.