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

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

Made XPM version of the icon 32x32.

Line 
1# Description: Shows how to select examples based on their attribute values
2# Category:    preprocessing
3# Uses:        imports-85
4# Classes:     Domain, select
5# Referenced:  domain.htm
6
7import orange
8
9def reportAttributes(dataset, header=None):
10  if dataset.domain.classVar:
11    print 'Class variable: %s,' % dataset.domain.classVar.name,
12  else:
13    print 'No Class,',
14  if header:
15    print '%s:' % header
16  for i in range(len(dataset.domain.attributes)):
17    print "%s" % dataset.domain.attributes[i].name,
18    if i % 6 == 5: print
19  print "\n"
20
21filename = "imports-85.tab"
22data = orange.ExampleTable(filename)
23reportAttributes(data, "Original data set")
24
25newData1 = data.select(range(5))
26reportAttributes(newData1, "First five attributes")
27
28newData2 = data.select(['engine-location', 'wheel-base', 'length'])
29reportAttributes(newData2, "Attributes selected by name")
30
31domain3 = orange.Domain([data.domain[0], data.domain['curb-weight'], data.domain[2]])
32newData3 = data.select(domain3)
33reportAttributes(newData3, "Attributes by domain")
34
35domain4 = orange.Domain([data.domain[0], data.domain['curb-weight'], data.domain[2]], 0)
36newData4 = data.select(domain4)
37reportAttributes(newData4, "Attributes by domain")
Note: See TracBrowser for help on using the repository browser.