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

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

Changed data set path.

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