Changeset 7424:efa1f32fdb41 in orange


Ignore:
Timestamp:
02/04/11 12:40:48 (3 years ago)
Author:
tomazc <tomaz.curk@…>
Branch:
default
Convert:
b83491f1a9adf8d5b56e7a8a6226115fedf83f65
Message:

Documentatio and code refactoring at Bohinj retreat.

Location:
orange
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • orange/Orange/feature/scoring.py

    r7405 r7424  
    479479from orange import MeasureAttribute_cost as Cost 
    480480from orange import MeasureAttribute_relief as Relief 
     481from orange import MeasureAttribute_MSE as MSE 
    481482 
    482483###### 
  • orange/doc/Orange/rst/code/scoring-diff-measures.py

    r7374 r7424  
    55# Referenced:  MeasureAttribute.htm 
    66 
    7 import orange, random 
    8 data = orange.ExampleTable("measure") 
     7import Orange 
     8import random 
     9table = Orange.data.Table("measure") 
    910 
    10 data2 = orange.ExampleTable(data) 
     11table2 = Orange.data.Table(table) 
    1112nulls = [(0, 1, 24, 25), (24, 25), range(24, 34), (24, 25)] 
    1213for attr in range(len(nulls)): 
    1314    for e in nulls[attr]: 
    14         data2[e][attr]="?" 
     15        table2[e][attr]="?" 
    1516 
    16 names = [a.name for a in data.domain.attributes] 
     17names = [a.name for a in table.domain.attributes] 
    1718attrs = len(names) 
    1819print 
     
    2122 
    2223def printVariants(meas): 
    23     print fstr % (("- no unknowns:",) + tuple([meas(i, data) for i in range(attrs)])) 
     24    print fstr % (("- no unknowns:",) + tuple([meas(i, table) for i in range(attrs)])) 
    2425 
    2526    meas.unknownsTreatment = meas.IgnoreUnknowns 
    26     print fstr % (("- ignore unknowns:",) + tuple([meas(i, data2) for i in range(attrs)])) 
     27    print fstr % (("- ignore unknowns:",) + tuple([meas(i, table2) for i in range(attrs)])) 
    2728 
    2829    meas.unknownsTreatment = meas.ReduceByUnknowns 
    29     print fstr % (("- reduce unknowns:",) + tuple([meas(i, data2) for i in range(attrs)])) 
     30    print fstr % (("- reduce unknowns:",) + tuple([meas(i, table2) for i in range(attrs)])) 
    3031 
    3132    meas.unknownsTreatment = meas.UnknownsToCommon 
    32     print fstr % (("- unknowns to common:",) + tuple([meas(i, data2) for i in range(attrs)])) 
     33    print fstr % (("- unknowns to common:",) + tuple([meas(i, table2) for i in range(attrs)])) 
    3334 
    3435    meas.unknownsTreatment = meas.UnknownsAsValue 
    35     print fstr % (("- unknowns as value:",) + tuple([meas(i, data2) for i in range(attrs)])) 
     36    print fstr % (("- unknowns as value:",) + tuple([meas(i, table2) for i in range(attrs)])) 
    3637    print 
    37      
     38 
    3839print "Information gain" 
    39 printVariants(orange.MeasureAttribute_info()) 
     40printVariants(Orange.feature.scoring.InfoGain()) 
    4041 
    4142print "Gain ratio" 
    42 printVariants(orange.MeasureAttribute_gainRatio()) 
     43printVariants(Orange.feature.scoring.GainRatio()) 
    4344 
    4445print "Gini index" 
    45 printVariants(orange.MeasureAttribute_gini()) 
     46printVariants(Orange.feature.scoring.Gini()) 
    4647 
    4748print "Relief" 
    48 meas = orange.MeasureAttribute_relief() 
    49 print fstr % (("- no unknowns:",) + tuple([meas(i, data) for i in range(attrs)])) 
    50 print fstr % (("- with unknowns:",) + tuple([meas(i, data2) for i in range(attrs)])) 
     49meas = Orange.feature.scoring.Relief() 
     50print fstr % (("- no unknowns:",) + tuple([meas(i, table) for i in range(attrs)])) 
     51print fstr % (("- with unknowns:",) + tuple([meas(i, table2) for i in range(attrs)])) 
    5152print 
    5253 
    5354print "Cost matrix ((0, 5), (1, 0))" 
    54 meas = orange.MeasureAttribute_cost() 
     55meas = Orange.feature.scoring.Cost() 
    5556meas.cost = ((0, 5), (1, 0)) 
    5657printVariants(meas) 
    5758 
    5859print "Relevance" 
    59 printVariants(orange.MeasureAttribute_relevance()) 
     60printVariants(Orange.feature.scoring.Relevance()) 
  • orange/doc/Orange/rst/code/scoring-regression.py

    r7374 r7424  
    55# Referenced:  MeasureAttribute.htm 
    66 
    7 import orange, random 
    8 data = orange.ExampleTable("measure-c") 
     7import Orange 
     8import random 
     9data = Orange.data.Table("measure-c") 
    910 
    10 data2 = orange.ExampleTable(data) 
     11data2 = Orange.data.Table(data) 
    1112nulls = [(0, 1, 24, 25), (24, 25), range(24, 34), (24, 25)] 
    1213for attr in range(len(nulls)): 
     
    3435     
    3536print "MSE" 
    36 printVariants(orange.MeasureAttribute_MSE()) 
     37printVariants(Orange.feature.scoring.MSE()) 
    3738 
    3839print "Relief" 
    39 meas = orange.MeasureAttribute_relief() 
     40meas = Orange.feature.scoring.Relief() 
    4041print fstr % (("- no unknowns:",) + tuple([meas(i, data) for i in range(attrs)])) 
    4142print fstr % (("- with unknowns:",) + tuple([meas(i, data2) for i in range(attrs)])) 
  • orange/doc/Orange/rst/code/selection-bayes.py

    r7418 r7424  
    2121       
    2222    def __call__(self, table, weight=None): 
    23         ma = orngFSS.attMeasure(table) 
    24         filtered = orngFSS.selectBestNAtts(table, ma, self.N) 
     23        ma = Orange.feature.scoring.attMeasure(table) 
     24        filtered = Orange.feature.selection.selectBestNAtts(table, ma, self.N) 
    2525        model = Orange.classification.bayes.NaiveLearner(filtered) 
    2626        return BayesFSS_Classifier(classifier=model, N=self.N, name=self.name) 
  • orange/doc/Orange/rst/code/selection-filtered-learner.py

    r7319 r7424  
    1111table = Orange.data.Table("voting") 
    1212 
    13 nb = Orange.classification.bayes.NaiveBayesLearner() 
     13nb = Orange.classification.bayes.NaiveLearner() 
    1414fl = Orange.feature.selection.FilteredLearner(nb,  
    1515     filter=Orange.feature.selection.FilterBestNAtts(n=1), name='filtered') 
    16 learners = (Orange.classification.bayes.NaiveBayesLearner(name='bayes'), fl) 
     16learners = (Orange.classification.bayes.NaiveLearner(name='bayes'), fl) 
    1717results = orngTest.crossValidation(learners, table, storeClassifiers=1) 
    1818 
Note: See TracChangeset for help on using the changeset viewer.