API Reference
Documentation for the OptimalTrees public interface.
Index
- IAI.OptimalTreeClassifier
- IAI.OptimalTreeLearner
- IAI.OptimalTreeMultiClassifier
- IAI.OptimalTreeMultiLearner
- IAI.OptimalTreeMultiRegressor
- IAI.OptimalTreePolicyMaximizer
- IAI.OptimalTreePolicyMinimizer
- IAI.OptimalTreePrescriptionMaximizer
- IAI.OptimalTreePrescriptionMinimizer
- IAI.OptimalTreeRegressor
- IAI.OptimalTreeSurvivalLearner
- IAI.copy_splits_and_refit_leaves!
- IAI.prune_trees!
- IAI.refit_leaves!
Learners
IAI.OptimalTreeLearner — TypeAbstract type encompassing all optimal tree learners.
IAI.OptimalTreeClassifier — TypeLearner for training Optimal Classification Trees.
The following parameters are supported (refer to the documentation for each):
IAI.OptimalTreeRegressor — TypeLearner for training Optimal Regression Trees.
The following parameters are supported (refer to the documentation for each):
IAI.OptimalTreeSurvivalLearner — TypeLearner for training Optimal Survival Trees.
The following parameters are supported (refer to the documentation for each):
IAI.OptimalTreePrescriptionMinimizer — TypeLearner for training Optimal Prescriptive Trees where the prescriptions should aim to minimize outcomes.
The following parameters are supported (refer to the documentation for each):
IAI.OptimalTreePrescriptionMaximizer — TypeLearner for training Optimal Prescriptive Trees where the prescriptions should aim to maximize outcomes.
Supports the same parameters as OptimalTreePrescriptionMinimizer.
IAI.OptimalTreePolicyMinimizer — TypeLearner for training Optimal Policy Trees where the prescriptions should aim to minimize outcomes.
The following parameters are supported (refer to the documentation for each):
IAI.OptimalTreePolicyMaximizer — TypeLearner for training Optimal Policy Trees where the prescriptions should aim to maximize outcomes.
Supports the same parameters as OptimalTreePolicyMinimizer.
IAI.OptimalTreeMultiLearner — TypeAbstract type encompassing all multi-task optimal tree learners.
IAI.OptimalTreeMultiClassifier — TypeLearner for training multi-task Optimal Classification Trees.
The following parameters are supported (refer to the documentation for each):
- all OptimalTreeClassifierparameters
- shared multi-task Learnerparameters
IAI.OptimalTreeMultiRegressor — TypeLearner for training multi-task Optimal Regression Trees.
The following parameters are supported (refer to the documentation for each):
- all OptimalTreeRegressorparameters
- shared multi-task Learnerparameters
Tree Refitting
IAI.refit_leaves! — Functionrefit_leaves!(lnr::OptimalTreeLearner, X::FeatureInput, y::TargetInput...;
              keyword_arguments...)Refit the models in the leaves of the trained tree of lnr using the supplied data X and y.
See the guide to classification trees with logistic regression for an example of using this function to refit a classification tree with logistic regression in each leaf.
Keyword Arguments
- sample_weight::SampleWeightInput=nothing: the weighting to give to each data point
- criterion=:default: the scoring criterion to use when updating the leaf models
- refit_learner::Union{Nothing,Learner,GridSearch}=nothing: an optional learner or grid search that is used to fit the new model in each leaf
- prune::Bool=false: whether to prune leaves of the tree that do not contain any of the supplied data. If set to- falseand there are leaves that do not contain any of the supplied data, an error will be thrown.
IAI.copy_splits_and_refit_leaves! — Functioncopy_splits_and_refit_leaves!(new_lnr::OptimalTreeLearner,
                              orig_lnr::OptimalTreeLearner,
                              X::FeatureInput, y::TargetInput...;
                              keyword_arguments...)Copy the tree split structure from orig_lnr into new_lnr and refit the models in each leaf of the tree using data X and y.
See the guide to classification trees with logistic regression for an example of using this function to convert a regression tree into a classification tree with logistic regression models in each leaf.
Supports the same keyword arguments as refit_leaves!.
IAI.prune_trees! — Functionprune_trees!(lnr::OptimalTreeLearner, X::FeatureInput, y::TargetInput...;
             keyword_arguments...)Use the trained trees in lnr along with the supplied validation data X and y to determine the best value for the cp parameter and then prune the trees according to this value.
This can be useful for re-pruning trees to an appropriate level of complexity after using refit_leaves! or copy_splits_and_refit_leaves! to change the models in each leaf.
Keyword Arguments
- reselect_best_tree::Bool(required): whether to re-select the tree used by the learner. If- false, the pruned version of the original tree used by the learner will be used. If- true, the pruned tree with the best training performance will be used.
- sample_weight::SampleWeightInput=nothing: the weighting to give to each data point
- criterion=:default: the scoring criterion to use when updating the leaf models