API Reference

API Reference

Documentation for the IAITrees public interface.

Index

Types

IAI.TreeLearnerType.

Abstract type encompassing all tree-based learners.

Abstract type encompassing all tree-based learners with classification leaves.

Abstract type encompassing all tree-based learners with regression leaves.

Abstract type encompassing all tree-based learners with survival leaves.

Abstract type encompassing all tree-based learners with prescription leaves.

Tree Structure

These functions can be used to query the structure of a TreeLearner. The examples make use of the following tree:

Optimal Trees Visualization
IAI.get_num_nodesFunction.
get_num_nodes(lnr::TreeLearner)

Return the number of nodes in the trained lnr.

Example

IAI.get_num_nodes(lnr)
7
IAI.is_leafFunction.
is_leaf(lnr::TreeLearner, node_index::Int)

Return true if node node_index in the trained lnr is a leaf.

Example

IAI.is_leaf(lnr, 1)
false
IAI.get_depthFunction.
get_depth(lnr::TreeLearner, node_index::Int)

Return the depth of node node_index in the trained lnr.

Example

IAI.get_depth(lnr, 6)
2
IAI.get_num_samplesFunction.
get_num_samples(lnr::TreeLearner, node_index::Int)

Return the number of training points contained in node node_index in the trained lnr.

Example

IAI.get_num_samples(lnr, 6)
97
IAI.get_parentFunction.
get_parent(lnr::TreeLearner, node_index::Int)

Return the index of the parent of node node_index in the trained lnr.

Example

IAI.get_parent(lnr, 2)
1
IAI.get_lower_childFunction.
get_lower_child(lnr::TreeLearner, node_index::Int)

Return the index of the lower child of node node_index in the trained lnr.

Example

IAI.get_lower_child(lnr, 1)
2
IAI.get_upper_childFunction.
get_upper_child(lnr::TreeLearner, node_index::Int)

Return the index of the upper child of node node_index in the trained lnr.

Example

IAI.get_upper_child(lnr, 1)
5
IAI.is_parallel_splitFunction.
is_parallel_split(lnr::TreeLearner, node_index::Int)

Return true if node node_index in the trained lnr is a parallel split.

Example

IAI.is_parallel_split(lnr, 1)
true
is_hyperplane_split(lnr::TreeLearner, node_index::Int)

Return true if node node_index in the trained lnr is a hyperplane split.

Example

IAI.is_hyperplane_split(lnr, 2)
true
is_categoric_split(lnr::TreeLearner, node_index::Int)

Return true if node node_index in the trained lnr is a categoric split.

Example

IAI.is_categoric_split(lnr, 5)
true
IAI.is_ordinal_splitFunction.
is_ordinal_split(lnr::TreeLearner, node_index::Int)

Return true if node node_index in the trained lnr is an ordinal split.

Example

IAI.is_ordinal_split(lnr, 1)
false
is_mixed_parallel_split(lnr::TreeLearner, node_index::Int)

Return true if node node_index in the trained lnr is a mixed categoric/parallel split.

Example

IAI.is_mixed_parallel_split(lnr, 2)
false
is_mixed_ordinal_split(lnr::TreeLearner, node_index::Int)

Return true if node node_index in the trained lnr is a mixed categoric/ordinal split.

Example

IAI.is_mixed_ordinal_split(lnr, 5)
false
missing_goes_lower(lnr::TreeLearner, node_index::Int)

Return true if missing values take the lower branch at node node_index in the trained lnr.

Applies to non-leaf nodes.

Example

IAI.missing_goes_lower(lnr, 1)
false
IAI.get_split_featureFunction.
get_split_feature(lnr::TreeLearner, node_index::Int)

Return the feature used in the split at node node_index in the trained lnr.

Applies to categoric, ordinal, parallel, categoric/ordinal, and categoric/parallel splits.

Example

IAI.get_split_feature(lnr, 1)
:score1
get_split_threshold(lnr::TreeLearner, node_index::Int)

Return the threshold used in the split at node node_index in the trained lnr.

Applies to hyperplane, parallel, and categoric/parallel splits.

Example

IAI.get_split_threshold(lnr, 1)
49.79228179001239
get_split_categories(lnr::TreeLearner, node_index::Int)

Return a Dict containing the categoric/ordinal information used in the split at node node_index in the trained lnr, where the keys are the levels used in the split and the values are true if that level follows the lower branch and false if that level follows the upper branch.

Applies to categoric, ordinal, categoric/ordinal, and categoric/parallel splits.

Example

IAI.get_split_categories(lnr, 5)
Dict{Any,Bool} with 5 entries:
  "B" => true
  "A" => true
  "C" => false
  "D" => false
  "E" => false
IAI.get_split_weightsFunction.
get_split_weights(lnr::TreeLearner, node_index::Int)

Return two Dicts containing the weights for numeric and categoric features, respectively, used in the hyperplane split at node node_index in the trained lnr.

The numeric Dict has key-value pairs of feature names and their corresponding weights in the hyperplane split.

The categoric Dict has key-value pairs of feature names and a corresponding Dict that maps the categoric levels for that feature to their weights in the hyperplane.

Any features not included in either Dict has zero weight in the hyperplane, and similarly, any categoric levels that are not included have zero weight.

Applies to hyperplane splits.

Example

numeric_weights, categoric_weights = IAI.get_split_weights(lnr, 2)
numeric_weights
Dict{Symbol,Float64} with 2 entries:
  :score3 => 2.04785
  :score2 => 0.0101001
categoric_weights
Dict{Symbol,Dict{Any,Float64}} with 1 entry:
  :region => Dict{Any,Float64}("E"=>1.51766)

Classification

These functions can be used to query the structure of a ClassificationTreeLearner. The examples make use of the following tree:

Optimal Trees Visualization
get_classification_label(lnr::ClassificationTreeLearner, node_index::Int)

Return the predicted label at node node_index in the trained lnr.

Applies to leaf nodes.

Example

IAI.get_classification_label(lnr, 2)
"setosa"
get_classification_proba(lnr::ClassificationTreeLearner, node_index::Int)

Return the predicted probabilities of class membership at node node_index in the trained lnr.

Applies to leaf nodes.

Example

IAI.get_classification_proba(lnr, 4)
Dict{String,Float64} with 3 entries:
  "virginica"  => 0.0925926
  "setosa"     => 0.0
  "versicolor" => 0.907407

Regression

These functions can be used to query the structure of a RegressionTreeLearner. The examples make use of the following tree:

Optimal Trees Visualization
get_regression_constant(lnr::RegressionTreeLearner, node_index::Int)

Return the constant term in the regression prediction at node node_index in the trained lnr.

Applies to leaf nodes.

Example

IAI.get_regression_constant(lnr, 2)
30.879999999999995
IAI.get_regression_constant(lnr, 3)
26.56192034262967
get_regression_weights(lnr::RegressionTreeLearner, node_index::Int)

Return the weights for each feature in the regression prediction at node node_index in the trained lnr. The weights are returned as two Dicts in the same format as described for get_split_weights.

Applies to leaf nodes.

Example

numeric_weights, categoric_weights = IAI.get_regression_weights(lnr, 3)
numeric_weights
Dict{Symbol,Float64} with 2 entries:
  :Disp => -0.0210445
  :HP   => -0.0188614
categoric_weights
Dict{Symbol,Dict{Any,Float64}} with 0 entries

Survival

These functions can be used to query the structure of a SurvivalTreeLearner. The examples make use of the following tree:

Optimal Trees Visualization