Changeset 7393:8652e6e70355 in orange


Ignore:
Timestamp:
02/04/11 10:06:47 (3 years ago)
Author:
crt <crtomir.gorup@…>
Branch:
default
Convert:
b82347c17d68af73516b138c883761ad02c3df40
Message:

Improved documentation.

Location:
orange/Orange/ensemble
Files:
4 edited

Legend:

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

    r7369 r7393  
    88 
    99================== 
    10 Boosting 
    11 ================== 
     10Bagging 
     11================== 
     12BaggedLearner takes a learner and returns a bagged learner, which is  
     13essentially a wrapper around the learner passed as an argument. If  
     14examples are passed in arguments, BaggedLearner returns a bagged  
     15classifiers. Both learner and classifier then behave just like any  
     16other learner and classifier in Orange. 
     17 
     18Bagging, in essence, takes a training data and a learner, and builds t  
     19classifiers each time presenting a learner a bootstrap sample from the  
     20training data. When given a test example, classifiers vote on class,  
     21and a bagged classifier returns a class with a highest number of votes.  
     22As implemented in Orange, when class probabilities are requested, these  
     23are proportional to the number of votes for a particular class. 
     24 
    1225.. index:: ensembleboosting 
    1326.. autoclass:: Orange.ensemble.bagging.BaggedLearner 
    1427   :members: 
    15  
    16 ================== 
    17 Bagging 
    18 ================== 
     28   :show-inheritance: 
     29 
     30================== 
     31Boosting 
     32================== 
     33Instead of drawing a series of bootstrap samples from the training set, 
     34bootstrap maintains a weight for each instance. When classifier is  
     35trained from the training set, the weights for misclassified instances  
     36are increased. Just like in bagged learner, the class is decided based  
     37on voting of classifiers, but in boosting votes are weighted by accuracy  
     38obtained on training set. 
     39 
     40BoostedLearner is an implementation of AdaBoost.M1 (Freund and Shapire,  
     411996). From user's viewpoint, the use of the BoostedLearner is similar to  
     42that of BaggedLearner. The learner passed as an argument needs to deal  
     43with example weights. 
     44 
    1945.. index:: ensemblebagging 
    2046.. autoclass:: Orange.ensemble.boosting.BoostedLearner 
    2147  :members: 
     48  :show-inheritance: 
    2249 
    2350Example 
     
    4673Forest 
    4774================== 
     75Just like bagging, classifiers in random forests are trained from bootstrap 
     76samples of training data. Here, classifiers are trees, but to increase 
     77randomness build in the way that at each node the best attribute is chosen 
     78from a subset of attributes in the training set. We closely follows the 
     79original algorithm (Brieman, 2001) both in implementation and parameter 
     80defaults. 
     81 
     82.. note:: 
     83    Random forest classifier uses decision trees induced from bootstrapped 
     84    training set to vote on class of presented example. Most frequent vote 
     85    is returned. However, in our implementation, if class probability is 
     86    requested from a classifier, this will return the averaged probabilities 
     87    from each of the trees. 
    4888 
    4989.. index:: randomforest 
    5090.. autoclass:: Orange.ensemble.forest.RandomForestLearner 
    5191  :members: 
     92  :show-inheritance: 
    5293 
    5394 
  • orange/Orange/ensemble/bagging.py

    r7369 r7393  
    1616 
    1717class BaggedLearner(orange.Learner): 
    18     """ 
    19     BaggedLearner takes a learner and returns a bagged learner, which is  
    20     essentially a wrapper around the learner passed as an argument. If  
    21     examples are passed in arguments, BaggedLearner returns a bagged  
    22     classifiers. Both learner and classifier then behave just like any  
    23     other learner and classifier in Orange. 
    24      
    25     Bagging, in essence, takes a training data and a learner, and builds t  
    26     classifiers each time presenting a learner a bootstrap sample from the  
    27     training data. When given a test example, classifiers vote on class,  
    28     and a bagged classifier returns a class with a highest number of votes.  
    29     As implemented in Orange, when class probabilities are requested, these  
    30     are proportional to the number of votes for a particular class. 
     18    """:param learner: A learner to be bagged. 
     19    :type learner: :class:`Orange.core.Learner` 
     20    :param examples: If examples are passed to BaggedLearner, this returns 
     21        a BaggedClassifier, that is, creates t classifiers using learner  
     22        and a subset of examples, as appropriate for bagging. 
     23    :type examples: :class:`Orange.data.Table` 
     24    :param t: Number of bagged classifiers, that is, classifiers created 
     25        when examples are passed to bagged learner. 
     26    :type t: int 
     27    :param name: The name of the learner. 
     28    :type name: string 
     29    :rtype: :class:`Orange.ensemble.bagging.BaggedClassifier` or  
     30            :class:`Orange.ensemble.bagging.BaggedLearner` 
    3131    """ 
    3232    def __new__(cls, learner, examples=None, weightId=None, **kwargs): 
     
    3939         
    4040    def __init__(self, learner, t=10, name='Bagging'): 
    41         """:param learner: A learner to be bagged. 
    42         :type learner: :class:`Orange.core.Learner` 
    43         :param examples: If examples are passed to BaggedLearner, this returns 
    44             a BaggedClassifier, that is, creates t classifiers using learner  
    45             and a subset of examples, as appropriate for bagging. 
    46         :type examples: :class:`Orange.data.Table` 
    47         :param t: Number of bagged classifiers, that is, classifiers created 
    48             when examples are passed to bagged learner. 
    49         :type t: int 
    50         :param name: The name of the learner. 
    51         :type name: string 
    52         :rtype: :class:`Orange.ensemble.bagging.BaggedClassifier` or  
    53                 :class:`Orange.ensemble.bagging.BaggedLearner` 
    54         """ 
    5541        self.t = t 
    5642        self.name = name 
  • orange/Orange/ensemble/boosting.py

    r7369 r7393  
    1313 
    1414class BoostedLearner(orange.Learner): 
    15     """ 
    16     Instead of drawing a series of bootstrap samples from the training set, 
    17     bootstrap maintains a weight for each instance. When classifier is  
    18     trained from the training set, the weights for misclassified instances  
    19     are increased. Just like in bagged learner, the class is decided based  
    20     on voting of classifiers, but in boosting votes are weighted by accuracy  
    21     obtained on training set. 
    22  
    23     BoostedLearner is an implementation of AdaBoost.M1 (Freund and Shapire,  
    24     1996). From user's viewpoint, the use of the BoostedLearner is similar to  
    25     that of BaggedLearner. The learner passed as an argument needs to deal  
    26     with example weights. 
     15    """:param learner: A learner to be bagged. 
     16    :type learner: :class:`Orange.core.Learner` 
     17    :param examples: If examples are passed to BoostedLearner, 
     18        this returns a BoostedClassifier, that is, creates t  
     19        classifiers using learner and a subset of examples,  
     20        as appropriate for AdaBoost.M1 (default: None). 
     21    :type examples: :class:`Orange.data.Table` 
     22    :param t: Number of boosted classifiers created from the example set. 
     23    :type t: int 
     24    :param name: The name of the learner. 
     25    :type name: string 
     26    :rtype: :class:`Orange.ensemble.boosting.BoostedClassifier` or  
     27            :class:`Orange.ensemble.boosting.BoostedLearner` 
    2728    """ 
    2829    def __new__(cls, learner, examples=None, weightId=None, **kwargs): 
     
    3536 
    3637    def __init__(self, learner, t=10, name='AdaBoost.M1'): 
    37         """:param learner: A learner to be bagged. 
    38         :type learner: :class:`Orange.core.Learner` 
    39         :param examples: If examples are passed to BoostedLearner, 
    40             this returns a BoostedClassifier, that is, creates t  
    41             classifiers using learner and a subset of examples,  
    42             as appropriate for AdaBoost.M1 (default: None). 
    43         :type examples: :class:`Orange.data.Table` 
    44         :param t: Number of boosted classifiers created from the example set. 
    45         :type t: int 
    46         :param name: The name of the learner. 
    47         :type name: string 
    48         :rtype: :class:`Orange.ensemble.boosting.BoostedClassifier` or  
    49                 :class:`Orange.ensemble.boosting.BoostedLearner`""" 
    5038        self.t = t 
    5139        self.name = name 
  • orange/Orange/ensemble/forest.py

    r7369 r7393  
    88 
    99class RandomForestLearner(orange.Learner): 
     10    """:param examples: If these are passed, the call returns  
     11            RandomForestClassifier, that is, creates the required set of 
     12            decision trees, which, when presented with an examples, vote 
     13            for the predicted class. 
     14    :type examples: :class:`Orange.data.Table` 
     15    :param trees: Number of trees in the forest. 
     16    :type trees: int 
     17    :param learner: Although not required, one can use this argument 
     18            to pass one's own tree induction algorithm. If None is passed 
     19            , RandomForestLearner will use Orange's tree induction  
     20            algorithm such that in induction nodes with less then 5  
     21            examples will not be considered for (further) splitting. 
     22    :type learner: :class:`Orange.core.Learner` 
     23    :param attributes: Number of attributes used in a randomly drawn 
     24            subset when searching for best attribute to split the node 
     25            in tree growing (default: None, and if kept this way, this 
     26            is turned into square root of attributes in the training set, 
     27            when this is presented to learner). 
     28    :param rand: Random generator used in bootstrap sampling.  
     29            If none is passed, then Python's Random from random library is  
     30            used, with seed initialized to 0. 
     31    :type rand: function 
     32    :param callback:  A function to be called after every iteration of 
     33            induction of classifier. This is called with parameter  
     34            (from 0.0 to 1.0) that gives estimates on learning progress. 
     35    :param name: The name of the learner. 
     36    :type name: string 
     37    :rtype: :class:`Orange.ensemble.forest.RandomForestClassifier` or  
     38            :class:`Orange.ensemble.forest.RandomForestLearner` 
    1039    """ 
    11     Just like bagging, classifiers in random forests are trained from bootstrap 
    12     samples of training data. Here, classifiers are trees, but to increase 
    13     randomness build in the way that at each node the best attribute is chosen 
    14     from a subset of attributes in the training set. We closely follows the 
    15     original algorithm (Brieman, 2001) both in implementation and parameter 
    16     defaults. 
    17  
    18     .. note:: 
    19         Random forest classifier uses decision trees induced from bootstrapped 
    20         training set to vote on class of presented example. Most frequent vote 
    21         is returned. However, in our implementation, if class probability is 
    22         requested from a classifier, this will return the averaged probabilities 
    23         from each of the trees. 
    24     """ 
     40 
    2541    def __new__(cls, examples=None, weight = 0, **kwds): 
    2642        self = orange.Learner.__new__(cls, **kwds) 
     
    3349    def __init__(self, learner=None, trees=100, attributes=None,\ 
    3450                    name='Random Forest', rand=None, callback=None): 
    35         """:param examples: If these are passed, the call returns  
    36                 RandomForestClassifier, that is, creates the required set of 
    37                 decision trees, which, when presented with an examples, vote 
    38                 for the predicted class. 
    39         :type examples: :class:`Orange.data.Table` 
    40         :param trees: Number of trees in the forest. 
    41         :type trees: int 
    42         :param learner: Although not required, one can use this argument 
    43                 to pass one's own tree induction algorithm. If None is passed 
    44                 , RandomForestLearner will use Orange's tree induction  
    45                 algorithm such that in induction nodes with less then 5  
    46                 examples will not be considered for (further) splitting. 
    47         :type learner: :class:`Orange.core.Learner` 
    48         :param attributes: Number of attributes used in a randomly drawn 
    49                 subset when searching for best attribute to split the node 
    50                 in tree growing (default: None, and if kept this way, this 
    51                 is turned into square root of attributes in the training set, 
    52                 when this is presented to learner). 
    53         :param rand: Random generator used in bootstrap sampling.  
    54                 If none is passed, then Python's Random from random library is  
    55                 used, with seed initialized to 0. 
    56         :type rand: function 
    57         :param callback:  A function to be called after every iteration of 
    58                 induction of classifier. This is called with parameter  
    59                 (from 0.0 to 1.0) that gives estimates on learning progress. 
    60         :param name: The name of the learner. 
    61         :type name: string 
    62         :rtype: :class:`Orange.ensemble.forest.RandomForestClassifier` or  
    63                 :class:`Orange.ensemble.forest.RandomForestLearner`""" 
    6451        self.trees = trees 
    6552        self.name = name 
Note: See TracChangeset for help on using the changeset viewer.