sklearn_pmml_model.tree.tree
#
Module Contents#
Classes#
A decision tree classifier. |
|
A decision tree regressor. |
Functions#
|
Convert a multiSplit into a binarySplit decision tree which is expressively equivalent. |
|
Generate nodes and values used for constructing Cython Tree class. |
|
Construct a single tree for a <Segment> PMML element. |
|
Clone a DecisionTree, including private properties that are ignored in sklearn.base.clone. |
Attributes#
- sklearn_pmml_model.tree.tree.SPLIT_UNDEFINED#
- class sklearn_pmml_model.tree.tree.PMMLTreeClassifier(pmml)#
Bases:
sklearn_pmml_model.base.PMMLBaseClassifier
,sklearn.tree.DecisionTreeClassifier
A decision tree classifier.
The PMML model consists out of a <TreeModel> element, containing at least one <Node> element. Every node element contains a predicate, and optional <Node> children. Leaf nodes either have a score attribute or <ScoreDistribution> child describing the classification output.
- Parameters:
- pmmlstr, object
Filename or file object containing PMML data.
Notes
Specification: http://dmg.org/pmml/v4-3/TreeModel.html
- fit(x, y)#
Not supported: PMML models are already fitted.
- _more_tags()#
- class sklearn_pmml_model.tree.tree.PMMLTreeRegressor(pmml)#
Bases:
sklearn_pmml_model.base.PMMLBaseRegressor
,sklearn.tree.DecisionTreeRegressor
A decision tree regressor.
The PMML model consists out of a <TreeModel> element, containing at least one <Node> element. Every node element contains a predicate, and optional <Node> children. Leaf nodes either have a score attribute or <ScoreDistribution> child describing the classification output.
- Parameters:
- pmmlstr, object
Filename or file object containing PMML data.
Notes
Specification: http://dmg.org/pmml/v4-3/TreeModel.html
- fit(x, y)#
Not supported: PMML models are already fitted.
- _more_tags()#
- sklearn_pmml_model.tree.tree.unflatten(node)#
Convert a multiSplit into a binarySplit decision tree which is expressively equivalent.
- Parameters:
- nodeeTree.Element
XML Node element representing the current node.
- Returns:
- nodeeTree.Element
Modified XML Node element representing the flattened decision tree.
- sklearn_pmml_model.tree.tree.construct_tree(node, classes, field_mapping, i=0, rescale_factor=1)#
Generate nodes and values used for constructing Cython Tree class.
- Parameters:
- nodeeTree.Element
XML Node element representing the current node.
- classeslist, None
List of possible target classes. Is None for regression trees.
- field_mapping: { str: (int, callable) }
Dictionary mapping column names to tuples with 1) index of the column and 2) type of the column.
- iint
Index of the node in the result list.
- rescale_factorfloat
Factor to scale the output of every node with. Required for gradient boosting trees. Optional, and 1 by default.
- Returns:
- (nodes, values)tuple
- nodes[()]
List of nodes represented by: left child (int), right child (int), feature (int), value (int for categorical, float for continuous), impurity (float), sample count (int) and weighted sample count (int).
- values[[]]
List with training sample distributions at this node in the tree.
- sklearn_pmml_model.tree.tree.get_tree(est, segment, rescale_factor=1) object #
Construct a single tree for a <Segment> PMML element.
- Parameters:
- est:
The estimator to built the tree for. Should contain template_estimator and field_mapping attributes.
- segmenteTree.Element
<Segment> element containing the decision tree to be imported. Only segments with a <True/> predicate are supported.
- rescale_factorfloat
Factor to scale the output of every node with. Required for gradient boosting trees. Optional, and 1 by default.
- Returns:
- treesklearn.tree.DecisionTreeClassifier, sklearn.tree.DecisionTreeRegressor
The sklearn decision tree instance imported from the provided segment, matching the type specified in est.template_estimator.
- sklearn_pmml_model.tree.tree.clone(est, safe=True)#
Clone a DecisionTree, including private properties that are ignored in sklearn.base.clone.
- Parameters:
- estBaseEstimator
The estimator or group of estimators to be cloned.
- safeboolean, optional
If safe is false, clone will fall back to a deep copy on objects that are not estimators.