Ignore:
Timestamp:
02/06/12 09:11:20 (2 years ago)
Author:
Miha Stajdohar <miha.stajdohar@…>
Branch:
default
Message:

To Orange25.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • docs/reference/rst/code/selection-bayes.py

    r9372 r9661  
    33# Uses:        voting 
    44# Referenced:  Orange.feature.html#selection 
    5 # Classes:     Orange.feature.scoring.score_all, Orange.feature.selection.bestNAtts 
     5# Classes:     Orange.feature.scoring.score_all, Orange.feature.selection.best_n 
    66 
    77import Orange 
     
    1515        else: 
    1616            return learner 
    17      
     17 
    1818    def __init__(self, name='Naive Bayes with FSS', N=5): 
    1919        self.name = name 
    2020        self.N = 5 
    21        
    22     def __call__(self, table, weight=None): 
    23         ma = Orange.feature.scoring.score_all(table) 
    24         filtered = Orange.feature.selection.selectBestNAtts(table, ma, self.N) 
     21 
     22    def __call__(self, data, weight=None): 
     23        ma = Orange.feature.scoring.score_all(data) 
     24        filtered = Orange.feature.selection.select_best_n(data, ma, self.N) 
    2525        model = Orange.classification.bayes.NaiveLearner(filtered) 
    2626        return BayesFSS_Classifier(classifier=model, N=self.N, name=self.name) 
     
    2929    def __init__(self, **kwds): 
    3030        self.__dict__.update(kwds) 
    31      
    32     def __call__(self, example, resultType = Orange.core.GetValue): 
     31 
     32    def __call__(self, example, resultType=Orange.core.GetValue): 
    3333        return self.classifier(example, resultType) 
    3434 
    3535 
    3636# test above wraper on a data set 
    37 table = Orange.data.Table("voting") 
     37voting = Orange.data.Table("voting") 
    3838learners = (Orange.classification.bayes.NaiveLearner(name='Naive Bayes'), 
    3939            BayesFSS(name="with FSS")) 
    40 results = Orange.evaluation.testing.cross_validation(learners, table) 
     40results = Orange.evaluation.testing.cross_validation(learners, voting) 
    4141 
    4242# output the results 
Note: See TracChangeset for help on using the changeset viewer.