Ignore:
Timestamp:
02/06/12 18:25:09 (2 years ago)
Author:
blaz <blaz.zupan@…>
Branch:
default
Message:

polished discretization

File:
1 edited

Legend:

Unmodified
Added
Removed
  • docs/reference/rst/code/discretization.py

    r9372 r9812  
    99 
    1010print "\nEntropy discretization, first 10 examples" 
    11 sep_w = Orange.feature.discretization.EntropyDiscretization("sepal width", data) 
     11sep_w = Orange.feature.discretization.Entropy("sepal width", data) 
    1212 
    1313data2 = data.select([data.domain["sepal width"], sep_w, data.domain.class_var]) 
     
    1919print "Cut-off points:", sep_w.get_value_from.transformer.points 
    2020 
    21 print "\nManual construction of IntervalDiscretizer - single attribute" 
    22 idisc = Orange.feature.discretization.IntervalDiscretizer(points = [3.0, 5.0]) 
     21print "\nManual construction of Interval discretizer - single attribute" 
     22idisc = Orange.feature.discretization.Interval(points = [3.0, 5.0]) 
    2323sep_l = idisc.construct_variable(data.domain["sepal length"]) 
    2424data2 = data.select([data.domain["sepal length"], sep_l, data.domain.classVar]) 
     
    2727 
    2828 
    29 print "\nManual construction of IntervalDiscretizer - all attributes" 
    30 idisc = Orange.feature.discretization.IntervalDiscretizer(points = [3.0, 5.0]) 
     29print "\nManual construction of Interval discretizer - all attributes" 
     30idisc = Orange.feature.discretization.Interval(points = [3.0, 5.0]) 
    3131newattrs = [idisc.construct_variable(attr) for attr in data.domain.attributes] 
    3232data2 = data.select(newattrs + [data.domain.class_var]) 
     
    3535 
    3636 
    37 print "\n\nEqual interval size discretization" 
    38 disc = Orange.feature.discretization.EquiDistDiscretization(numberOfIntervals = 6) 
     37print "\n\nDiscretization with equal width intervals" 
     38disc = Orange.feature.discretization.EqualWidth(numberOfIntervals = 6) 
    3939newattrs = [disc(attr, data) for attr in data.domain.attributes] 
    4040data2 = data.select(newattrs + [data.domain.classVar]) 
     
    5151 
    5252 
    53 print "\n\nQuartile discretization" 
    54 disc = Orange.feature.discretization.EquiNDiscretization(numberOfIntervals = 6) 
     53print "\n\nQuartile (equal frequency) discretization" 
     54disc = Orange.feature.discretization.EqualFreq(numberOfIntervals = 6) 
    5555newattrs = [disc(attr, data) for attr in data.domain.attributes] 
    5656data2 = data.select(newattrs + [data.domain.classVar]) 
     
    6666 
    6767 
    68 print "\nManual construction of EquiDistDiscretizer - all attributes" 
    69 edisc = Orange.feature.discretization.EquiDistDiscretizer(first_cut = 2.0, step = 1.0, number_of_intervals = 5) 
     68print "\nManual construction of EqualWidth - all attributes" 
     69edisc = Orange.feature.discretization.EqualWidth(first_cut = 2.0, step = 1.0, number_of_intervals = 5) 
    7070newattrs = [edisc.constructVariable(attr) for attr in data.domain.attributes] 
    7171data2 = data.select(newattrs + [data.domain.classVar]) 
     
    7474 
    7575 
    76 print "\nFayyad-Irani discretization" 
    77 entro = Orange.feature.discretization.EntropyDiscretization() 
     76print "\nFayyad-Irani entropy-based discretization" 
     77entro = Orange.feature.discretization.Entropy() 
    7878for attr in data.domain.attributes: 
    7979    disc = entro(attr, data) 
     
    8787data_v = Orange.data.Table(newdomain, data) 
    8888 
    89 print "\nBi-Modal discretization on binary problem" 
    90 bimod = Orange.feature.discretization.BiModalDiscretization(split_in_two = 0) 
     89print "\nBi-modal discretization on a binary problem" 
     90bimod = Orange.feature.discretization.BiModal(split_in_two = 0) 
    9191for attr in data_v.domain.attributes: 
    9292    disc = bimod(attr, data_v) 
     
    9494print 
    9595 
    96 print "\nBi-Modal discretization on binary problem" 
    97 bimod = Orange.feature.discretization.BiModalDiscretization() 
     96print "\nBi-modal discretization on a binary problem" 
     97bimod = Orange.feature.discretization.BiModal() 
    9898for attr in data_v.domain.attributes: 
    9999    disc = bimod(attr, data_v) 
     
    102102 
    103103 
    104 print "\nEntropy discretization on binary problem" 
     104print "\nEntropy-based discretization on a binary problem" 
    105105for attr in data_v.domain.attributes: 
    106106    disc = entro(attr, data_v) 
Note: See TracChangeset for help on using the changeset viewer.