Package nltk :: Package classify :: Module decisiontree :: Class DecisionTreeClassifier
[hide private]
[frames] | no frames]

type DecisionTreeClassifier

source code

     object --+    
              |    
api.ClassifierI --+
                  |
                 DecisionTreeClassifier

Instance Methods [hide private]
 
__init__(self, label, feature_name=None, decisions=None, default=None) source code
list of (immutable)
labels(self)
Returns: the list of category labels used by this classifier.
source code
label
classify(self, featureset)
Returns: the most appropriate label for the given featureset.
source code
 
error(self, labeled_featuresets) source code
 
pp(self, width=70, prefix='', depth=4)
Return a string containing a pretty-printed version of this decision tree.
source code
 
pseudocode(self, prefix='', depth=4)
Return a string representation of this decision tree that expresses the decisions it makes as a nested set of pseudocode if statements.
source code
 
__str__(self) source code
 
refine(self, labeled_featuresets, entropy_cutoff, depth_cutoff, support_cutoff, binary=False, feature_values=None, verbose=False) source code

Inherited from api.ClassifierI: batch_classify, batch_prob_classify, prob_classify

    Deprecated

Inherited from api.ClassifierI: batch_probdist, probdist

Static Methods [hide private]
 
train(labeled_featuresets, entropy_cutoff=0.05, depth_cutoff=100, support_cutoff=10, binary=False, feature_values=None, verbose=False) source code
 
leaf(labeled_featuresets) source code
 
stump(feature_name, labeled_featuresets) source code
 
best_stump(feature_names, labeled_featuresets, verbose=False) source code
 
binary_stump(feature_name, feature_value, labeled_featuresets) source code
 
best_binary_stump(feature_names, labeled_featuresets, feature_values, verbose=False) source code
Method Details [hide private]

__init__(self, label, feature_name=None, decisions=None, default=None)
(Constructor)

source code 
Parameters:
  • label - The most likely label for tokens that reach this node in the decision tree. If this decision tree has no children, then this label will be assigned to any token that reaches this decision tree.
  • feature_name - The name of the feature that this decision tree selects for.
  • decisions - A dictionary mapping from feature values for the feature identified by feature_name to child decision trees.
  • default - The child that will be used if the value of feature feature_name does not match any of the keys in decisions. This is used when constructing binary decision trees.
Overrides: object.__init__

labels(self)

source code 
Returns: list of (immutable)
the list of category labels used by this classifier.
Overrides: api.ClassifierI.labels
(inherited documentation)

classify(self, featureset)

source code 
Returns: label
the most appropriate label for the given featureset.
Overrides: api.ClassifierI.classify
(inherited documentation)

pp(self, width=70, prefix='', depth=4)

source code 

Return a string containing a pretty-printed version of this decision tree. Each line in this string corresponds to a single decision tree node or leaf, and indentation is used to display the structure of the decision tree.

__str__(self)
(Informal representation operator)

source code 
Overrides: object.__str__
(inherited documentation)

train(labeled_featuresets, entropy_cutoff=0.05, depth_cutoff=100, support_cutoff=10, binary=False, feature_values=None, verbose=False)
Static Method

source code 
Parameters:
  • binary - If true, then treat all feature/value pairs a individual binary features, rather than using a single n-way branch for each feature.