source: orange/orange/doc/ofb/domain6.py @ 6538:a5f65d7f0b2c

Revision 6538:a5f65d7f0b2c, 744 bytes checked in by Mitar <Mitar@…>, 4 years ago (diff)

Made XPM version of the icon 32x32.

Line 
1# Description: Shows how to use Filter_sameValues for instance selection
2# Category:    preprocessing
3# Uses:        imports-85
4# Classes:     
5# Referenced:  domain.htm
6
7import orange
8
9def report_prob(header, data):
10  print 'Size of %s: %i instances; ' % (header, len(data)), 
11  n = 0
12  for i in data:
13    if int(i.getclass())==0:
14      n = n + 1
15  if len(data):
16    print "p(%s)=%5.3f" % (data.domain.classVar.values[0], float(n)/len(data))
17  else:
18    print
19
20filename = "../datasets/adult_sample.tab"
21data = orange.ExampleTable(filename)
22report_prob('data', data)
23
24data1 = data.select(age=(30,40))
25report_prob('data1, age from 30 to 40', data1)
26
27data2 = data.select(age=(40,30))
28report_prob('data2, younger than 30 or older than 40', data2)
Note: See TracBrowser for help on using the repository browser.