rdkit.ML.DecTree.DecTree.DecTreeNode

Package rdkit :: Package ML :: Package DecTree :: Module DecTree :: Class DecTreeNode |
[hide private]
[frames] | no frames]

# Class DecTreeNode

source code

    Tree.TreeNode --+
                    |
                   DecTreeNode

Known Subclasses:
  - SigTree.SigTreeNode
  - , QuantTree.QuantTreeNode

    This is used to represent decision trees

    _DecTreeNode_s are simultaneously the roots and branches of decision trees.
    Everything is nice and recursive.

    _DecTreeNode_s can save the following pieces of internal state, accessible via
      standard setter/getter functions:

      1) _Examples_: a list of examples which have been classified

      2) _BadExamples_: a list of examples which have been misclassified

      3) _TrainingExamples_: the list of examples used to train the tree

      4) _TestExamples_: the list of examples used to test the tree

Instance Methods | [hide private]
__init__(self, *args, **kwargs) constructor | source code
ClassifyExample(self, example, appendExamples=0) Recursively classify an example by running it through the tree | source code
AddChild(self, name, label=None, data=None, isTerminal=0) Constructs and adds a child with the specified data to our list | source code
GetExamples(self) | source code
SetExamples(self, examples) | source code
GetBadExamples(self) | source code
SetBadExamples(self, examples) | source code
GetTrainingExamples(self) | source code
SetTrainingExamples(self, examples) | source code
GetTestExamples(self) | source code
SetTestExamples(self, examples) | source code
ClearExamples(self) | source code
Inherited from `Tree.TreeNode`: `AddChildNode`, `Destroy`, `GetChildren`, `GetData`, `GetLabel`, `GetLevel`, `GetName`, `GetParent`, `GetTerminal`, `NameModel`, `NameTree`, `Pickle`, `Print`, `PruneChild`, `ReplaceChildIndex`, `SetData`, `SetLabel`, `SetLevel`, `SetName`, `SetParent`, `SetTerminal`, `__cmp__`, `__str__`

Method Details | [hide private]

### __init__(self, *args, **kwargs) (Constructor) | source code
    constructor

    **Arguments**

      - parent: the parent of this node in the tree

      - name: the name of the node

      - label: the node's label (should be an integer)

      - data: an optional data field

      - level: an integer indicating the level of this node in the hierarchy
        (used for printing)

      - isTerminal: flags a node as being terminal.  This is useful for those
        times when it's useful to know such things.
Overrides: Tree.TreeNode.__init__ (inherited documentation)

### ClassifyExample(self, example, appendExamples=0) | source code
    Recursively classify an example by running it through the tree

    **Arguments**

      - example: the example to be classified

      - appendExamples: if this is nonzero then this node (and all children)
        will store the example

    **Returns**

      the classification of _example_

    **NOTE:**
      In the interest of speed, I don't use accessor functions
      here.  So if you subclass DecTreeNode for your own trees, you'll
      have to either include ClassifyExample or avoid changing the names
      of the instance variables this needs.

### AddChild(self, name, label=None, data=None, isTerminal=0) | source code
    Constructs and adds a child with the specified data to our list

    **Arguments**

     - name: the name of the new node

     - label: the label of the new node (should be an integer)

     - data: the data to be stored in the new node

     - isTerminal: a toggle to indicate whether or not the new node is
       a terminal (leaf) node.

    **Returns*

      the _DecTreeNode_ which is constructed
Overrides: Tree.TreeNode.AddChild