Changeset 9318:658d8849d4e9 in orange


Ignore:
Timestamp:
12/06/11 15:21:19 (2 years ago)
Author:
markotoplak
Branch:
default
Convert:
61d7f81b9abd2832695e8452d884fa8e4326379f
Message:

Feature scoring adapted for SimpleTreeLearner.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orange/Orange/ensemble/forest.py

    r9317 r9318  
    7474        randomized with Random Forest's random 
    7575        feature subset selection.  If None (default), 
    76         :class:`~Orange.classification.tree.SimpleTreeLearner` and it will not split 
    77         nodes with less than 5 data instances. 
    78     :type base_learner: None or :class:`Orange.classification.tree.TreeLearner` or  
     76        :class:`~Orange.classification.tree.SimpleTreeLearner` and it 
     77        will not split nodes with less than 5 data instances. 
     78    :type base_learner: None or 
     79    :class:`Orange.classification.tree.TreeLearner` or 
    7980        :class:`Orange.classification.tree.SimpleTreeLearner` 
    8081    :param rand: random generator used in bootstrap sampling. If None (default),  
     
    279280        randomized with Random Forest's random 
    280281        feature subset selection.  If None (default), 
    281         :class:`~Orange.classification.tree.TreeLearner` with Gini index 
    282         or MSE for attribute scoring will be used, and it will not split 
    283         nodes with less than 5 data instances. 
    284     :type base_learner: None or :class:`Orange.classification.tree.TreeLearner` 
     282        :class:`~Orange.classification.tree.SimpleTreeLearner` and it 
     283        will not split nodes with less than 5 data instances. 
     284    :type base_learner: None or 
     285    :class:`Orange.classification.tree.TreeLearner` or 
     286        :class:`Orange.classification.tree.SimpleTreeLearner` 
    285287    :param rand: random generator used in bootstrap sampling. If None (default),  
    286288        then ``random.Random(0)`` is used. 
    287     :param learner: Tree induction learner. If None (default),  
    288         the :obj:`~ScoreFeature.base_learner` will be used (and randomized). If 
    289         :obj:`~ScoreFeature.learner` is specified, it will be used as such 
     289    :param learner: Tree induction learner. If `None` (default),  
     290        the :obj:`base_learner` will be used (and randomized). If 
     291        :obj:`learner` is specified, it will be used as such 
    290292        with no additional transformations. 
    291293    :type learner: None or :class:`Orange.core.Learner` 
    292  
    293294    """ 
    294295    def __init__(self, trees=100, attributes=None, rand=None, base_learner=None, learner=None): 
     
    300301        self.rand = rand 
    301302        self.base_learner = base_learner 
     303 
     304        if base_learner != None and learner != None: 
     305            wrongSpecification() 
     306 
    302307        if not self.rand: 
    303308            self.rand = random.Random(0) 
    304         if self.learner == None: 
    305             self.learner = _default_small_learner(attributes=self.attributes, rand=self.rand, base=self.base_learner) 
     309        self.randorange = Orange.core.RandomGenerator(self.rand.randint(0,2**31-1)) 
     310 
     311        if learner == None: 
     312            self.learner = _wrap_learner(base=self.base_learner, rand=self.rand, randorange=self.randorange) 
     313        else: 
     314            self.learner = learner 
    306315   
    307316    def __call__(self, feature, instances, apriorClass=None): 
     
    425434            right = self._numRight(oob, cla) 
    426435             
    427             presl = list(self._presentInTree(cla.tree, attrnum)) 
     436            presl = range(attrs) 
     437            try: #FIXME SimpleTreeLearner does not know how to output attributes yet 
     438                presl = list(self._presentInTree(cla.tree, attrnum)) 
     439            except: 
     440                pass 
    428441                       
    429442            #randomize each feature in data and test 
Note: See TracChangeset for help on using the changeset viewer.