API Reference
Documentation for the IAITrees
public interface.
Index
IAI.Questionnaire
IAI.ClassificationTreeLearner
IAI.ClassificationTreeMultiLearner
IAI.MultiTreePlot
IAI.MultiTreePlot
IAI.PolicyTreeLearner
IAI.PrescriptionTreeLearner
IAI.RegressionTreeLearner
IAI.RegressionTreeMultiLearner
IAI.SimilarityComparison
IAI.StabilityAnalysis
IAI.SurvivalTreeLearner
IAI.TreeLearner
IAI.TreeMultiLearner
IAI.TreePlot
IAI.show_in_browser
IAI.show_questionnaire
IAI.variable_importance
IAI.write_html
IAI.write_questionnaire
IAI.apply
IAI.apply_nodes
IAI.compare_group_outcomes
IAI.decision_path
IAI.get_classification_label
IAI.get_classification_label
IAI.get_classification_label
IAI.get_classification_proba
IAI.get_classification_proba
IAI.get_classification_proba
IAI.get_cluster_assignments
IAI.get_cluster_details
IAI.get_cluster_distances
IAI.get_depth
IAI.get_lower_child
IAI.get_num_nodes
IAI.get_num_samples
IAI.get_parent
IAI.get_policy_treatment_outcome
IAI.get_policy_treatment_outcome_standard_error
IAI.get_policy_treatment_rank
IAI.get_prescription_treatment_rank
IAI.get_regression_constant
IAI.get_regression_constant
IAI.get_regression_constant
IAI.get_regression_constant
IAI.get_regression_constant
IAI.get_regression_constant
IAI.get_regression_constant
IAI.get_regression_constant
IAI.get_regression_weights
IAI.get_regression_weights
IAI.get_regression_weights
IAI.get_regression_weights
IAI.get_regression_weights
IAI.get_regression_weights
IAI.get_regression_weights
IAI.get_regression_weights
IAI.get_split_categories
IAI.get_split_feature
IAI.get_split_threshold
IAI.get_split_weights
IAI.get_stability_results
IAI.get_survival_curve
IAI.get_survival_expected_time
IAI.get_survival_hazard
IAI.get_train_errors
IAI.get_tree
IAI.get_upper_child
IAI.is_categoric_split
IAI.is_hyperplane_split
IAI.is_leaf
IAI.is_mixed_ordinal_split
IAI.is_mixed_parallel_split
IAI.is_ordinal_split
IAI.is_parallel_split
IAI.missing_goes_lower
IAI.print_path
IAI.reset_display_label!
IAI.set_display_label!
IAI.set_threshold!
IAI.variable_importance_similarity
IAI.write_dot
IAI.write_pdf
IAI.write_png
IAI.write_svg
Types
IAI.TreeLearner
— TypeAbstract type encompassing all tree-based learners.
IAI.ClassificationTreeLearner
— TypeAbstract type encompassing all tree-based learners with classification leaves.
IAI.RegressionTreeLearner
— TypeAbstract type encompassing all tree-based learners with regression leaves.
IAI.SurvivalTreeLearner
— TypeAbstract type encompassing all tree-based learners with survival leaves.
IAI.PrescriptionTreeLearner
— TypeAbstract type encompassing all tree-based learners with prescription leaves.
IAI.PolicyTreeLearner
— TypeAbstract type encompassing all tree-based learners with policy leaves.
IAI.TreeMultiLearner
— TypeAbstract type encompassing all multi-task tree-based learners.
IAI.ClassificationTreeMultiLearner
— TypeAbstract type encompassing all multi-task tree-based learners with classification leaves.
IAI.RegressionTreeMultiLearner
— TypeAbstract type encompassing all multi-task tree-based learners with regression leaves.
Tree Structure
These functions can be used to query the structure of a TreeLearner
. The examples make use of the following tree:
IAI.get_num_nodes
— Functionget_num_nodes(lnr::TreeLearner)
Return the number of nodes in the trained lnr
.
Example
IAI.get_num_nodes(lnr)
7
IAI.is_leaf
— Functionis_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_depth
— Functionget_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_samples
— Functionget_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)
78
IAI.get_parent
— Functionget_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_child
— Functionget_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_child
— Functionget_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_split
— Functionis_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
IAI.is_hyperplane_split
— Functionis_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
IAI.is_categoric_split
— Functionis_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_split
— Functionis_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
IAI.is_mixed_parallel_split
— Functionis_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
IAI.is_mixed_ordinal_split
— Functionis_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
IAI.missing_goes_lower
— Functionmissing_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_feature
— Functionget_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
IAI.get_split_threshold
— Functionget_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)
60.04421
IAI.get_split_categories
— Functionget_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" => 1
"A" => 1
"C" => 0
"D" => 0
"E" => 0
IAI.get_split_weights
— Functionget_split_weights(lnr::TreeLearner, node_index::Int)
Return two Dict
s 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 => 1.20415
:score2 => 0.0189015
categoric_weights
Dict{Symbol, Dict{Any, Float64}} with 1 entry:
:region => Dict("E"=>1.47922)
Classification
These functions can be used to query the structure of a ClassificationTreeLearner
. The examples make use of the following tree:
IAI.get_classification_label
— Methodget_classification_label(lnr::ClassificationTreeLearner, node_index::Int;
check_leaf::Bool=true)
Return the predicted label at node node_index
in the trained lnr
.
Applies to leaf nodes by default, set check_leaf=false
to enable retrieving the same information from a split node as though it was a leaf node.
Example
IAI.get_classification_label(lnr, 2)
"setosa"
IAI.get_classification_proba
— Methodget_classification_proba(lnr::ClassificationTreeLearner, node_index::Int;
check_leaf::Bool=true)
Return the predicted probabilities of class membership at node node_index
in the trained lnr
.
Applies to leaf nodes by default, set check_leaf=false
to enable retrieving the same information from a split node as though it was a leaf node.
Example
IAI.get_classification_proba(lnr, 4)
Dict{String, Float64} with 3 entries:
"virginica" => 0.0925926
"setosa" => 0.0
"versicolor" => 0.907407
IAI.get_regression_constant
— Methodget_regression_constant(lnr::ClassificationTreeLearner, node_index::Int;
check_leaf::Bool=true)
Return the constant term in the logistic regression prediction at node node_index
in the trained lnr
, or NaN
if the node does not contain a logistic regression model.
Applies to leaf nodes by default, set check_leaf=false
to enable retrieving the same information from a split node as though it was a leaf node.
IAI.get_regression_weights
— Methodget_regression_weights(lnr::ClassificationTreeLearner, node_index::Int;
check_leaf::Bool=true)
Return the weights for each feature in the logistic regression prediction at node node_index
in the trained lnr
. The weights are returned as two Dict
s in the same format as described for get_split_weights
.
Applies to leaf nodes by default, set check_leaf=false
to enable retrieving the same information from a split node as though it was a leaf node.
Regression
These functions can be used to query the structure of a RegressionTreeLearner
. The examples make use of the following tree:
IAI.get_regression_constant
— Methodget_regression_constant(lnr::RegressionTreeLearner, node_index::Int;
check_leaf::Bool=true)
Return the constant term in the regression prediction at node node_index
in the trained lnr
.
Applies to leaf nodes by default, set check_leaf=false
to enable retrieving the same information from a split node as though it was a leaf node.
Example
IAI.get_regression_constant(lnr, 2)
30.88
IAI.get_regression_constant(lnr, 3)
30.8876
IAI.get_regression_weights
— Methodget_regression_weights(lnr::RegressionTreeLearner, node_index::Int;
check_leaf::Bool=true)
Return the weights for each feature in the regression prediction at node node_index
in the trained lnr
. The weights are returned as two Dict
s in the same format as described for get_split_weights
.
Applies to leaf nodes by default, set check_leaf=false
to enable retrieving the same information from a split node as though it was a leaf node.
Example
numeric_weights, categoric_weights = IAI.get_regression_weights(lnr, 3)
numeric_weights
Dict{Symbol, Float64} with 4 entries:
:Cyl => -0.794566
:WT => -1.64974
:Gear => 0.0585196
:HP => -0.0126672
categoric_weights
Dict{Symbol, Dict{Any, Float64}}()
Survival
These functions can be used to query the structure of a SurvivalTreeLearner
. The examples make use of the following tree:
IAI.get_survival_curve
— Functionget_survival_curve(lnr::SurvivalTreeLearner, node_index::Int;
check_leaf::Bool=true)
Return the SurvivalCurve
fitted at node node_index
in the trained lnr
.
Applies to leaf nodes by default, set check_leaf=false
to enable retrieving the same information from a split node as though it was a leaf node.
Example
IAI.get_survival_curve(lnr, 2)
SurvivalCurve with 22 breakpoints
IAI.get_survival_expected_time
— Functionget_survival_expected_time(lnr::SurvivalTreeLearner, node_index::Int;
check_leaf::Bool=true)
Return the predicted expected survival time at node node_index
in the trained lnr
.
Applies to leaf nodes by default, set check_leaf=false
to enable retrieving the same information from a split node as though it was a leaf node.
Example
IAI.get_survival_expected_time(lnr, 2)
23443.187287749995
IAI.get_survival_hazard
— Functionget_survival_hazard(lnr::SurvivalTreeLearner, node_index::Int;
check_leaf::Bool=true)
Return the predicted hazard ratio at node node_index
in the trained lnr
.
Applies to leaf nodes by default, set check_leaf=false
to enable retrieving the same information from a split node as though it was a leaf node.
Example
IAI.get_survival_hazard(lnr, 2)
0.8880508
IAI.get_regression_constant
— Methodget_regression_constant(lnr::SurvivalTreeLearner, node_index::Int;
check_leaf::Bool=true)
Return the constant term in the Cox regression prediction at node node_index
in the trained lnr
, or NaN
if the node does not contain a Cox regression model.
Applies to leaf nodes by default, set check_leaf=false
to enable retrieving the same information from a split node as though it was a leaf node.
IAI.get_regression_weights
— Methodget_regression_weights(lnr::SurvivalTreeLearner, node_index::Int;
check_leaf::Bool=true)
Return the weights for each feature in the Cox regression prediction at node node_index
in the trained lnr
. The weights are returned as two Dict
s in the same format as described for get_split_weights
.
Applies to leaf nodes by default, set check_leaf=false
to enable retrieving the same information from a split node as though it was a leaf node.
Prescription
These functions can be used to query the structure of a PrescriptionTreeLearner
. The examples make use of the following tree:
IAI.get_prescription_treatment_rank
— Functionget_prescription_treatment_rank(lnr::PrescriptionTreeLearner,
node_index::Int; check_leaf::Bool=true)
Return a Vector
containing the treatments ordered from most effective to least effective at node node_index
in the trained lnr
.
Applies to leaf nodes by default, set check_leaf=false
to enable retrieving the same information from a split node as though it was a leaf node.
Example
IAI.get_prescription_treatment_rank(lnr, 2)
2-element Vector{String}:
"A"
"B"
IAI.get_regression_constant
— Methodget_regression_constant(lnr::PrescriptionTreeLearner, node_index::Int,
treatment::Any; check_leaf::Bool=true)
Return the constant in the regression prediction for treatment
at node node_index
in the trained lnr
.
Applies to leaf nodes by default, set check_leaf=false
to enable retrieving the same information from a split node as though it was a leaf node.
Example
IAI.get_regression_constant(lnr, 2, "A")
28.68282
IAI.get_regression_weights
— Methodget_regression_weights(lnr::PrescriptionTreeLearner, node_index::Int,
treatment::Any; check_leaf::Bool=true)
Return the weights for each feature in the regression prediction for treatment
at node node_index
in the trained lnr
. The weights are returned as two Dict
s in the same format as described for get_split_weights
.
Applies to leaf nodes by default, set check_leaf=false
to enable retrieving the same information from a split node as though it was a leaf node.
Example
numeric_weights, categoric_weights = IAI.get_regression_weights(lnr, 2, "A")
numeric_weights
Dict{Symbol, Float64} with 1 entry:
:SystolicBP => -1.37769
categoric_weights
Dict{Symbol, Dict{Any, Float64}}()
Policy
These functions can be used to query the structure of a PolicyTreeLearner
. The examples make use of the following tree: