source: orange/Orange/doc/reference/pp-missing.py @ 9671:a7b056375472

Revision 9671:a7b056375472, 1.3 KB checked in by anze <anze.staric@…>, 2 years ago (diff)

Moved orange to Orange (part 2)

Line 
1# Description: Shows how to remove or select examples with missing values
2# Category:    preprocessing, missing values
3# Classes:     Preprocessor, Preprocessor_addMissing, Preprocessor_addMissingClasses, Preprocessor_dropMissing, Preprocessor_dropMissingClasses, Preprocessor_takeMissing, Preprocessor_takeMissingClasses
4# Uses:        lenses
5# Referenced:  preprocessing.htm
6
7import orange
8data = orange.ExampleTable("lenses")
9age, prescr, astigm, tears, y = data.domain.variables
10
11pp = orange.Preprocessor_addMissingClasses()
12pp.proportion = 0.5
13pp.specialType = orange.ValueTypes.DK
14data2 = pp(data)
15
16print "Removing 50% of class values:",
17for ex in data2:
18    print ex.getclass(),
19print
20
21data2 = orange.Preprocessor_dropMissingClasses(data2)
22print "Removing examples with unknown class values:",
23for ex in data2:
24    print ex.getclass(),
25print
26
27print "\n\nRemoving 20% of values of 'age' and 50% of astigmatism:"
28pp = orange.Preprocessor_addMissing()
29pp.proportions = {age: 0.2, astigm: 0.5}
30pp.specialType = orange.ValueTypes.DC
31data2 = pp(data)
32for ex in data2:
33    print ex
34
35print "\n\nRemoving examples with unknown values"
36data3 = orange.Preprocessor_dropMissing(data2)
37for ex in data3:
38    print ex
39
40print "\n\nSelecting examples with unknown values"
41data3 = orange.Preprocessor_takeMissing(data2)
42for ex in data3:
43    print ex
44
45   
Note: See TracBrowser for help on using the repository browser.