Changeset 7397:42151bad78df in orange


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

Documentation reorder.

Location:
orange/Orange/ensemble
Files:
4 edited

Legend:

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

    r7393 r7397  
    1010Bagging 
    1111================== 
    12 BaggedLearner takes a learner and returns a bagged learner, which is  
    13 essentially a wrapper around the learner passed as an argument. If  
    14 examples are passed in arguments, BaggedLearner returns a bagged  
    15 classifiers. Both learner and classifier then behave just like any  
    16 other learner and classifier in Orange. 
    1712 
    18 Bagging, in essence, takes a training data and a learner, and builds t  
    19 classifiers each time presenting a learner a bootstrap sample from the  
    20 training data. When given a test example, classifiers vote on class,  
    21 and a bagged classifier returns a class with a highest number of votes.  
    22 As implemented in Orange, when class probabilities are requested, these  
    23 are proportional to the number of votes for a particular class. 
    24  
    25 .. index:: ensembleboosting 
     13.. index:: ensemble bagging 
    2614.. autoclass:: Orange.ensemble.bagging.BaggedLearner 
    2715   :members: 
     
    3119Boosting 
    3220================== 
    33 Instead of drawing a series of bootstrap samples from the training set, 
    34 bootstrap maintains a weight for each instance. When classifier is  
    35 trained from the training set, the weights for misclassified instances  
    36 are increased. Just like in bagged learner, the class is decided based  
    37 on voting of classifiers, but in boosting votes are weighted by accuracy  
    38 obtained on training set. 
    3921 
    40 BoostedLearner is an implementation of AdaBoost.M1 (Freund and Shapire,  
    41 1996). From user's viewpoint, the use of the BoostedLearner is similar to  
    42 that of BaggedLearner. The learner passed as an argument needs to deal  
    43 with example weights. 
    44  
    45 .. index:: ensemblebagging 
     22.. index:: ensemble boosting 
    4623.. autoclass:: Orange.ensemble.boosting.BoostedLearner 
    4724  :members: 
     
    7047 
    7148 
    72 ================== 
    73 Forest 
    74 ================== 
    75 Just like bagging, classifiers in random forests are trained from bootstrap 
    76 samples of training data. Here, classifiers are trees, but to increase 
    77 randomness build in the way that at each node the best attribute is chosen 
    78 from a subset of attributes in the training set. We closely follows the 
    79 original algorithm (Brieman, 2001) both in implementation and parameter 
    80 defaults. 
     49======= 
     50Random Forest 
     51======= 
    8152 
    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. 
    88  
    89 .. index:: randomforest 
     53.. index:: ensemble randomforest 
    9054.. autoclass:: Orange.ensemble.forest.RandomForestLearner 
    9155  :members: 
  • orange/Orange/ensemble/bagging.py

    r7393 r7397  
    1616 
    1717class BaggedLearner(orange.Learner): 
    18     """:param learner: A learner to be bagged. 
     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. 
     31     
     32    :param learner: learner to be bagged. 
    1933    :type learner: :class:`Orange.core.Learner` 
    20     :param examples: If examples are passed to BaggedLearner, this returns 
     34    :param examples: if examples are passed to BaggedLearner, this returns 
    2135        a BaggedClassifier, that is, creates t classifiers using learner  
    2236        and a subset of examples, as appropriate for bagging. 
    2337    :type examples: :class:`Orange.data.Table` 
    24     :param t: Number of bagged classifiers, that is, classifiers created 
     38    :param t: number of bagged classifiers, that is, classifiers created 
    2539        when examples are passed to bagged learner. 
    2640    :type t: int 
    27     :param name: The name of the learner. 
     41    :param name: name of the learner. 
    2842    :type name: string 
    2943    :rtype: :class:`Orange.ensemble.bagging.BaggedClassifier` or  
     
    4660        """Learn from the given table of data instances. 
    4761         
    48         :param instances: Data instances to learn from. 
     62        :param instances: data instances to learn from. 
    4963        :type instances: Orange.data.Table 
    50         :param weight: Id of meta attribute with weights of instances 
     64        :param weight: ID of meta attribute with weights of instances 
    5165        :type weight: int 
    5266        :rtype: :class:`Orange.ensemble.bagging.BaggedClassifier` 
  • orange/Orange/ensemble/boosting.py

    r7393 r7397  
    1313 
    1414class BoostedLearner(orange.Learner): 
    15     """:param learner: A learner to be bagged. 
     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. 
     27     
     28    :param learner: learner to be bagged. 
    1629    :type learner: :class:`Orange.core.Learner` 
    17     :param examples: If examples are passed to BoostedLearner, 
     30    :param examples: ff examples are passed to BoostedLearner, 
    1831        this returns a BoostedClassifier, that is, creates t  
    1932        classifiers using learner and a subset of examples,  
    2033        as appropriate for AdaBoost.M1 (default: None). 
    2134    :type examples: :class:`Orange.data.Table` 
    22     :param t: Number of boosted classifiers created from the example set. 
     35    :param t: number of boosted classifiers created from the example set. 
    2336    :type t: int 
    24     :param name: The name of the learner. 
     37    :param name: name of the learner. 
    2538    :type name: string 
    2639    :rtype: :class:`Orange.ensemble.boosting.BoostedClassifier` or  
     
    4356        """Learn from the given table of data instances. 
    4457         
    45         :param instances: Data instances to learn from. 
     58        :param instances: data instances to learn from. 
    4659        :type instances: Orange.data.Table 
    47         :param origWeight: Weight. 
     60        :param origWeight: weight. 
    4861        :type origWeight: int 
    4962        :rtype: :class:`Orange.ensemble.boosting.BoostedClassifier`""" 
  • orange/Orange/ensemble/forest.py

    r7393 r7397  
    66import random 
    77 
    8  
    98class RandomForestLearner(orange.Learner): 
    10     """:param examples: If these are passed, the call returns  
     9    """ 
     10    Just like bagging, classifiers in random forests are trained from bootstrap 
     11    samples of training data. Here, classifiers are trees, but to increase 
     12    randomness build in the way that at each node the best attribute is chosen 
     13    from a subset of attributes in the training set. We closely follows the 
     14    original algorithm (Brieman, 2001) both in implementation and parameter 
     15    defaults. 
     16 
     17    .. note:: 
     18        Random forest classifier uses decision trees induced from bootstrapped 
     19        training set to vote on class of presented example. Most frequent vote 
     20        is returned. However, in our implementation, if class probability is 
     21        requested from a classifier, this will return the averaged probabilities 
     22        from each of the trees. 
     23         
     24    :param examples: if these are passed, the call returns  
    1125            RandomForestClassifier, that is, creates the required set of 
    1226            decision trees, which, when presented with an examples, vote 
    1327            for the predicted class. 
    1428    :type examples: :class:`Orange.data.Table` 
    15     :param trees: Number of trees in the forest. 
     29    :param trees: number of trees in the forest. 
    1630    :type trees: int 
    17     :param learner: Although not required, one can use this argument 
     31    :param learner: although not required, one can use this argument 
    1832            to pass one's own tree induction algorithm. If None is passed 
    1933            , RandomForestLearner will use Orange's tree induction  
     
    2135            examples will not be considered for (further) splitting. 
    2236    :type learner: :class:`Orange.core.Learner` 
    23     :param attributes: Number of attributes used in a randomly drawn 
     37    :param attributes: number of attributes used in a randomly drawn 
    2438            subset when searching for best attribute to split the node 
    2539            in tree growing (default: None, and if kept this way, this 
    2640            is turned into square root of attributes in the training set, 
    2741            when this is presented to learner). 
    28     :param rand: Random generator used in bootstrap sampling.  
     42    :param rand: random generator used in bootstrap sampling.  
    2943            If none is passed, then Python's Random from random library is  
    3044            used, with seed initialized to 0. 
    3145    :type rand: function 
    32     :param callback:  A function to be called after every iteration of 
     46    :param callback: a function to be called after every iteration of 
    3347            induction of classifier. This is called with parameter  
    3448            (from 0.0 to 1.0) that gives estimates on learning progress. 
    35     :param name: The name of the learner. 
     49    :param name: name of the learner. 
    3650    :type name: string 
    3751    :rtype: :class:`Orange.ensemble.forest.RandomForestClassifier` or  
     
    7791        """Learn from the given table of data instances. 
    7892         
    79         :param instances: Data instances to learn from. 
     93        :param instances: data instances to learn from. 
    8094        :type instances: Orange.data.Table 
    81         :param origWeight: Weight. 
     95        :param origWeight: weight. 
    8296        :type origWeight: int 
    8397        :rtype: :class:`Orange.ensemble.forest.RandomForestClassifier`""" 
     
    142156 
    143157class MeasureAttribute_randomForests(orange.MeasureAttribute): 
     158    """:param trees: number of trees in the forest. 
     159    :type trees: int 
     160    :param learner: although not required, one can use this argument to pass 
     161        one's own tree induction algorithm. If None is  
     162        passed, :class:`Orange.ensemble.forest.MeasureAttribute` will  
     163        use Orange's tree induction algorithm such that in  
     164        induction nodes with less then 5 examples will not be  
     165        considered for (further) splitting. 
     166    :type learner: None or :class:`Orange.core.Learner` 
     167    :param attributes: number of attributes used in a randomly drawn 
     168        subset when searching for best attribute to split the node in tree 
     169        growing (default: None, and if kept this way, this is turned into 
     170        square root of attributes in example set). 
     171    :type attributes: int 
     172    :param rand: random generator used in bootstrap sampling. If None is  
     173        passed, then Python's Random from random library is used, with seed 
     174        initialized to 0.""" 
    144175    def __init__(self, learner=None, trees = 100, attributes=None, rand=None): 
    145         """:param trees: Number of trees in the forest. 
    146         :type trees: int 
    147         :param learner: Although not required, one can use this argument to pass 
    148             one's own tree induction algorithm. If None is  
    149             passed, :class:`Orange.ensemble.forest.MeasureAttribute` will  
    150             use Orange's tree induction algorithm such that in  
    151             induction nodes with less then 5 examples will not be  
    152             considered for (further) splitting. 
    153         :type learner: None or :class:`Orange.core.Learner` 
    154         :param attributes: Number of attributes used in a randomly drawn 
    155             subset when searching for best attribute to split the node in tree 
    156             growing (default: None, and if kept this way, this is turned into 
    157             square root of attributes in example set). 
    158         :type attributes: int 
    159         :param rand: Random generator used in bootstrap sampling. If None is  
    160             passed, then Python's Random from random library is used, with seed 
    161             initialized to 0.""" 
     176 
    162177        self.trees = trees 
    163178        self.learner = learner 
Note: See TracChangeset for help on using the changeset viewer.