Ignore:
Timestamp:
02/06/12 13:25:39 (2 years ago)
Author:
crt.gorup@…
Branch:
default
rebase_source:
52ef560e460d6dbc43513f55f66381fafdd802f1
Message:

Removed camelCase and added deprecated decorators.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Orange/ensemble/boosting.py

    r9671 r9733  
    2727            :class:`Orange.ensemble.boosting.BoostedLearner` 
    2828    """ 
    29     def __new__(cls, learner, instances=None, weightId=None, **kwargs): 
     29    def __new__(cls, learner, instances=None, weight_id=None, **kwargs): 
    3030        self = orange.Learner.__new__(cls, **kwargs) 
    3131        if instances is not None: 
    3232            self.__init__(self, learner, **kwargs) 
    33             return self.__call__(instances, weightId) 
     33            return self.__call__(instances, weight_id) 
    3434        else: 
    3535            return self 
     
    4040        self.learner = learner 
    4141 
    42     def __call__(self, instances, origWeight = 0): 
     42    def __call__(self, instances, orig_weight = 0): 
    4343        """ 
    4444        Learn from the given table of data instances. 
     
    4646        :param instances: data instances to learn from. 
    4747        :type instances: Orange.data.Table 
    48         :param origWeight: weight. 
    49         :type origWeight: int 
     48        :param orig_weight: weight. 
     49        :type orig_weight: int 
    5050        :rtype: :class:`Orange.ensemble.boosting.BoostedClassifier` 
    5151         
     
    5353        import math 
    5454        weight = Orange.data.new_meta_id() 
    55         if origWeight: 
     55        if orig_weight: 
    5656            for i in instances: 
    57                 i.setweight(weight, i.getweight(origWeight)) 
     57                i.setweight(weight, i.getweight(orig_weight)) 
    5858        else: 
    5959            instances.addMetaAttribute(weight, 1.0) 
     
    8080                instances.removeMetaAttribute(weight) 
    8181                return BoostedClassifier(classifiers = classifiers,  
    82                     name=self.name, classVar=instances.domain.classVar) 
     82                    name=self.name, class_var=instances.domain.class_var) 
    8383            beta = epsilon/(1-epsilon) 
    8484            for e in range(n): 
     
    9191        instances.removeMetaAttribute(weight) 
    9292        return BoostedClassifier(classifiers = classifiers, name=self.name,  
    93             classVar=instances.domain.classVar) 
     93            class_var=instances.domain.class_var) 
     94BoostedLearner = Orange.misc.deprecated_members({"examples":"instances", "classVar":"class_var", "weightId":"weigth_id", "origWeight":"orig_weight"})(BoostedLearner) 
    9495 
    9596class BoostedClassifier(orange.Classifier): 
     
    108109    :type name: str 
    109110     
    110     :param classVar: the class feature. 
    111     :type classVar: :class:`Orange.data.variable.Variable` 
     111    :param class_var: the class feature. 
     112    :type class_var: :class:`Orange.data.variable.Variable` 
    112113     
    113114    """ 
    114115 
    115     def __init__(self, classifiers, name, classVar, **kwds): 
     116    def __init__(self, classifiers, name, class_var, **kwds): 
    116117        self.classifiers = classifiers 
    117118        self.name = name 
    118         self.classVar = classVar 
     119        self.class_var = class_var 
    119120        self.__dict__.update(kwds) 
    120121 
    121     def __call__(self, instance, resultType = orange.GetValue): 
     122    def __call__(self, instance, result_type = orange.GetValue): 
    122123        """ 
    123124        :param instance: instance to be classified. 
     
    131132              :class:`Orange.statistics.Distribution` or a tuple with both 
    132133        """ 
    133         votes = Orange.statistics.distribution.Discrete(self.classVar) 
     134        votes = Orange.statistics.distribution.Discrete(self.class_var) 
    134135        for c, e in self.classifiers: 
    135136            votes[int(c(instance))] += e 
    136         index = Orange.misc.selection.selectBestIndex(votes) 
     137        index = Orange.misc.selection.select_best_index(votes) 
    137138        # TODO 
    138         value = Orange.data.Value(self.classVar, index) 
    139         if resultType == orange.GetValue: 
     139        value = Orange.data.Value(self.class_var, index) 
     140        if result_type == orange.GetValue: 
    140141            return value 
    141142        sv = sum(votes) 
    142143        for i in range(len(votes)): 
    143144            votes[i] = votes[i]/sv 
    144         if resultType == orange.GetProbabilities: 
     145        if result_type == orange.GetProbabilities: 
    145146            return votes 
    146         elif resultType == orange.GetBoth: 
     147        elif result_type == orange.GetBoth: 
    147148            return (value, votes) 
    148149        else: 
     
    150151         
    151152    def __reduce__(self): 
    152         return type(self), (self.classifiers, self.name, self.classVar), dict(self.__dict__) 
    153      
     153        return type(self), (self.classifiers, self.name, self.class_var), dict(self.__dict__) 
     154 
     155BoostedClassifier = Orange.misc.deprecated_members({"classVar":"class_var", "resultType":"result_type"})(BoostedClassifier) 
Note: See TracChangeset for help on using the changeset viewer.