API Reference

API Reference

Documentation for the iai package

Index

General Utilities

iai::iai_setupFunction.
iai_setup(...)

Initialize Julia and the IAI package.

This needs to be done in every R session before calling iai functions

Arguments

iai::set_julia_seedFunction.
set_julia_seed(seed)

Set the random seed in Julia

Julia Equivalent: Random.seed!

Arguments

  • seed: The seed to set
get_rich_output_params()

Return the current global rich output parameter settings

Julia Equivalent: IAI.get_rich_output_params

set_rich_output_param(key, value)

Sets a global rich output parameter

Julia Equivalent: IAI.set_rich_output_param!

Arguments

  • key: The parameter to set.
  • value: The value to set
delete_rich_output_param(key)

Delete a global rich output parameter

Julia Equivalent: IAI.delete_rich_output_param!

Arguments

  • key: The parameter to delete.
iai::show_in_browserFunction.
show_in_browser(obj, ...)

Show interactive visualization of an object (such as a learner or curve) in the default browser

Julia Equivalent: IAI.show_in_browser

Arguments

  • obj: The object to visualize.
  • ...: Refer to the Julia documentation for available parameters.

Data Preparation

iai::as.mixeddataFunction.
as.mixeddata(values, categorical_levels, ordinal_levels = c())

Convert a vector of values to IAI mixed data format

Julia Equivalent: IAI.make_mixed_data

Arguments

  • values: The vector of values to convert
  • categorical_levels: The values in values to treat as categoric levels
  • ordinal_levels: (optional) The values in values to treat as ordinal levels, in the order supplied
iai::split_dataFunction.
split_data(task, X, ...)

Split the data into training and test datasets

Julia Equivalent: IAI.split_data

Arguments

  • task: The type of problem.
  • X: The features of the data.
  • ...: Other parameters, including zero or more target vectors as required by the problem type. Refer to the Julia documentation for available parameters.

Learners

General learners

iai::fitFunction.
fit(lnr, X, ...)

Fits a model to the training data

Julia Equivalent: IAI.fit!

Arguments

  • lnr: The learner or grid to fit.
  • X: The features of the data.
  • ...: Other parameters, including zero or more target vectors as required by the problem type. Refer to the Julia documentation for available parameters.
iai::set_paramsFunction.
set_params(lnr, ...)

Set all supplied parameters on a learner

Julia Equivalent: IAI.set_params!

Arguments

  • lnr: The learner to modify.
  • ...: The parameters to set on the learner.
iai::get_paramsFunction.
get_params(lnr)

Return the value of all parameters on a learner

Julia Equivalent: IAI.get_params

Arguments

  • lnr: The learner to query.
iai::cloneFunction.
clone(lnr)

Return an unfitted copy of a learner with the same parameters

Julia Equivalent: IAI.clone

Arguments

  • lnr: The learner to copy.
iai::read_jsonFunction.
read_json(filename)

Read in a learner or grid saved in JSON format

Julia Equivalent: IAI.read_json

Arguments

  • filename: The location of the JSON file.
iai::write_jsonFunction.
write_json(filename, obj, ...)

Output a learner or grid in JSON format

Julia Equivalent: IAI.write_json

Arguments

  • filename: Where to save the output.
  • obj: The learner or grid to output.
  • ...: Refer to the Julia documentation for available parameters.

Supervised learners

iai::predictFunction.
predict(lnr, X)

Return the predictions made by the model for each point in the features

Julia Equivalent: IAI.predict

Arguments

  • lnr: The learner or grid to use for prediction.
  • X: The features of the data.
iai::scoreFunction.
score(lnr, X, ...)

Calculate the score for a model on the given data

Julia Equivalent: IAI.score

Arguments

  • lnr: The learner or grid to evaluate.
  • X: The features of the data.
  • ...: Other parameters, including zero or more target vectors as required by the problem type. Refer to the Julia documentation for available parameters.

Classification learners

iai::predict_probaFunction.
predict_proba(lnr, X)

Return the probabilities of class membership predicted by a model for each point in the features

Julia Equivalent: IAI.predict_proba

Arguments

  • lnr: The learner or grid to use for prediction.
  • X: The features of the data.
iai::roc_curveFunction.
roc_curve(lnr, X, y)

Construct an ROC curve using a trained model on the given data

Julia Equivalent: IAI.ROCCurve

Arguments

  • lnr: The learner or grid to use for prediction.
  • X: The features of the data.
  • y: The labels of the data.

Survival learners

get_survival_curve_data(curve)

Extract the underlying data from a survival curve (as returned by predict or get_survival_curve)

The data is returned as a list with two keys: times containing the time for each breakpoint on the curve, and coefs containing the probability for each breakpoint on the curve.

Julia Equivalent: IAI.get_survival_curve_data

Arguments

  • curve: The curve to query.

Prescription learners

iai::predict_outcomesFunction.
predict_outcomes(lnr, X)

Return the the predicted outcome for each treatment made by a model for each point in the features

Julia Equivalent: IAI.predict_outcomes

Arguments

  • lnr: The learner or grid to use for prediction.
  • X: The features of the data.

Imputation learners

iai::transformFunction.
transform(lnr, X)

Impute missing values in a dataframe using a fitted imputation model

Julia Equivalent: IAI.transform

Arguments

  • lnr: The learner or grid to use for imputation
  • X: The features of the data.
iai::fit_transformFunction.
fit_transform(lnr, X, ...)

Fit an imputation model using the given features and impute the missing values in these features

Similar to calling fit followed by transform

Julia Equivalent: IAI.fit_transform!

Arguments

  • lnr: The learner or grid to use for imputation
  • X: The features of the data.
  • ...: Refer to the Julia documentation for available parameters.

Grid Search

iai::grid_searchFunction.
grid_search(lnr, ...)

Controls grid search over parameter combinations

Julia Equivalent: IAI.GridSearch

Arguments

  • lnr: The learner to use when validating.
  • ...: The parameters to validate over.
iai::fit_cvFunction.
fit_cv(grid, X, ...)

Fits a grid search to the training data with cross-validation

Julia Equivalent: IAI.fit_cv!

Arguments

  • grid: The grid to fit.
  • X: The features of the data.
  • ...: Other parameters, including zero or more target vectors as required by the problem type. Refer to the Julia documentation for available parameters.
iai::fit_transform_cvFunction.
fit_transform_cv(grid, X, ...)

Train a grid using cross-validation with features and impute all missing values in these features

Julia Equivalent: IAI.fit_transform_cv!

Arguments

  • grid: The grid to use for imputation
  • X: The features of the data.
  • ...: Refer to the Julia documentation for available parameters.
iai::get_learnerFunction.
get_learner(grid)

Return the fitted learner using the best parameter combination from a grid

Julia Equivalent: IAI.get_learner

Arguments

  • grid: The grid to query.
iai::get_best_paramsFunction.
get_best_params(grid)

Return the best parameter combination from a grid

Julia Equivalent: IAI.get_best_params

Arguments

  • grid: The grid search to query.
iai::get_grid_resultsFunction.
get_grid_results(grid)

Return a summary of the results from the grid search

Julia Equivalent: IAI.get_grid_results

Arguments

  • grid: The grid search to query.

Tree Learners

General tree learners

iai::applyFunction.
apply(lnr, X)

Return the leaf index in a tree model into which each point in the features falls

Julia Equivalent: IAI.apply

Arguments

  • lnr: The learner or grid to query.
  • X: The features of the data.
iai::apply_nodesFunction.
apply_nodes(lnr, X)

Return the indices of the points in the features that fall into each node of a trained tree model

Julia Equivalent: IAI.apply_nodes

Arguments

  • lnr: The learner or grid to query.
  • X: The features of the data.
iai::decision_pathFunction.
decision_path(lnr, X)

Return a matrix where entry (i, j) is true if the ith point in the features passes through the jth node in a trained tree model.

Julia Equivalent: IAI.decision_path

Arguments

  • lnr: The learner or grid to query.
  • X: The features of the data.
iai::print_pathFunction.
print_path(lnr, X, ...)

Print the decision path through the learner for each sample in the features

Julia Equivalent: IAI.print_path

Arguments

  • lnr: The learner or grid to query.
  • X: The features of the data.
  • ...: Refer to the Julia documentation for available parameters.
variable_importance(lnr)

Generate a ranking of the variables in the learner according to their importance when training the trees

Julia Equivalent: IAI.variable_importance

Arguments

  • lnr: The learner or grid to query.
iai::get_num_nodesFunction.
get_num_nodes(lnr)

Return the number of nodes in a trained learner

Julia Equivalent: IAI.get_num_nodes

Arguments

  • lnr: The learner or grid to query.
iai::get_depthFunction.
get_depth(lnr, node_index)

Get the depth of a node of a tree

Julia Equivalent: IAI.get_depth

Arguments

  • lnr: The learner or grid to query.
  • node_index: The node in the tree to query.
iai::get_parentFunction.
get_parent(lnr, node_index)

Get the index of the parent node at a node of a tree

Julia Equivalent: IAI.get_parent

Arguments

  • lnr: The learner or grid to query.
  • node_index: The node in the tree to query.
iai::get_lower_childFunction.
get_lower_child(lnr, node_index)

Get the index of the lower child at a split node of a tree

Julia Equivalent: IAI.get_lower_child

Arguments

  • lnr: The learner or grid to query.
  • node_index: The node in the tree to query.
iai::get_upper_childFunction.
get_upper_child(lnr, node_index)

Get the index of the upper child at a split node of a tree

Julia Equivalent: IAI.get_upper_child

Arguments

  • lnr: The learner or grid to query.
  • node_index: The node in the tree to query.
iai::get_num_samplesFunction.
get_num_samples(lnr, node_index)

Get the number of training points contained in a node of a tree

Julia Equivalent: IAI.get_num_samples

Arguments

  • lnr: The learner or grid to query.
  • node_index: The node in the tree to query.
is_categoric_split(lnr, node_index)

Check if a node of a tree applies a categoric split

Julia Equivalent: IAI.is_categoric_split

Arguments

  • lnr: The learner or grid to query.
  • node_index: The node in the tree to query.
is_hyperplane_split(lnr, node_index)

Check if a node of a tree applies a hyperplane split

Julia Equivalent: IAI.is_hyperplane_split

Arguments

  • lnr: The learner or grid to query.
  • node_index: The node in the tree to query.
iai::is_leafFunction.
is_leaf(lnr, node_index)

Check if a node of a tree is a leaf

Julia Equivalent: IAI.is_leaf

Arguments

  • lnr: The learner or grid to query.
  • node_index: The node in the tree to query.
is_mixed_ordinal_split(lnr, node_index)

Check if a node of a tree applies a mixed ordinal/categoric split

Julia Equivalent: IAI.is_mixed_ordinal_split

Arguments

  • lnr: The learner or grid to query.
  • node_index: The node in the tree to query.
is_mixed_parallel_split(lnr, node_index)

Check if a node of a tree applies a mixed parallel/categoric split

Julia Equivalent: IAI.is_mixed_parallel_split

Arguments

  • lnr: The learner or grid to query.
  • node_index: The node in the tree to query.
iai::is_ordinal_splitFunction.
is_ordinal_split(lnr, node_index)

Check if a node of a tree applies a ordinal split

Julia Equivalent: IAI.is_ordinal_split

Arguments

  • lnr: The learner or grid to query.
  • node_index: The node in the tree to query.
is_parallel_split(lnr, node_index)

Check if a node of a tree applies a parallel split

Julia Equivalent: IAI.is_parallel_split

Arguments

  • lnr: The learner or grid to query.
  • node_index: The node in the tree to query.
get_split_categories(lnr, node_index)

Return the categoric/ordinal information used in the split at a node of a tree

Julia Equivalent: IAI.get_split_categories

Arguments

  • lnr: The learner or grid to query.
  • node_index: The node in the tree to query.
get_split_feature(lnr, node_index)

Return the feature used in the split at a node of a tree

Julia Equivalent: IAI.get_split_feature

Arguments

  • lnr: The learner or grid to query.
  • node_index: The node in the tree to query.
get_split_threshold(lnr, node_index)

Return the threshold used in the split at a node of a tree

Julia Equivalent: IAI.get_split_threshold

Arguments

  • lnr: The learner or grid to query.
  • node_index: The node in the tree to query.
get_split_weights(lnr, node_index)

Return the weights for numeric and categoric features used in the hyperplane split at a node of a tree

Julia Equivalent: IAI.get_split_weights

Arguments

  • lnr: The learner or grid to query.
  • node_index: The node in the tree to query.
missing_goes_lower(lnr, node_index)

Check if points with missing values go to the lower child at a split node of of a tree

Julia Equivalent: IAI.missing_goes_lower

Arguments

  • lnr: The learner or grid to query.
  • node_index: The node in the tree to query.

Classification tree learners

get_classification_label(lnr, node_index)

Return the predicted label at a node of a tree

Julia Equivalent: IAI.get_classification_label

Arguments

  • lnr: The learner or grid to query.
  • node_index: The node in the tree to query.
get_classification_proba(lnr, node_index)

Return the predicted probabilities of class membership at a node of a tree

Julia Equivalent: IAI.get_classification_proba

Arguments

  • lnr: The learner or grid to query.
  • node_index: The node in the tree to query.
iai::set_thresholdFunction.
set_threshold(lnr, label, threshold, ...)

For a binary classification problem, update the the predicted labels in the leaves of the learner to predict a label only if the predicted probability is at least the specified threshold.

Julia Equivalent: IAI.set_threshold!

Arguments

  • lnr: The learner or grid to modify.
  • label: The referenced label.
  • threshold: The probability threshold above which label will be be predicted.
  • ...: Refer to the Julia documentation for available parameters.
set_display_label(lnr, display_label)

Show the probability of a specified label when visualizing a learner

Julia Equivalent: IAI.set_display_label!

Arguments

  • lnr: The learner to modify.
  • display_label: The label for which to show probabilities.
reset_display_label(lnr)

Reset the predicted probability displayed to be that of the predicted label when visualizing a learner

Julia Equivalent: IAI.reset_display_label!

Arguments

  • lnr: The learner to modify.

Regression tree learners

get_regression_constant(lnr, node_index, ...)

Return the constant term in the regression prediction at a node of a tree

Julia Equivalent: IAI.get_regression_constant (for regression or prescription tree learners as appropriate)

Arguments

  • lnr: The learner or grid to query.
  • node_index: The node in the tree to query.
  • ...: If a prescription problem, the treatment to query.
get_regression_weights(lnr, node_index, ...)

Return the weights for each feature in the regression prediction at a node of a tree

Julia Equivalent: IAI.get_regression_weights (for regression or prescription tree learners as appropriate)

Arguments

  • lnr: The learner or grid to query.
  • node_index: The node in the tree to query.
  • ...: If a prescription problem, the treatment to query.

Survival tree learners

get_survival_curve(lnr, node_index)

Return the survival curve at a node of a tree

Julia Equivalent: IAI.get_survival_curve

Arguments

  • lnr: The learner or grid to query.
  • node_index: The node in the tree to query.

Prescription tree learners

get_prescription_treatment_rank(lnr, node_index)

Return the treatments ordered from most effective to least effective at a node of a tree

Julia Equivalent: IAI.get_prescription_treatment_rank

Arguments

  • lnr: The learner or grid to query.
  • node_index: The node in the tree to query.

Prescription tree learners also support:

Tree learner visualization

iai::write_pngFunction.
write_png(filename, lnr, ...)

Output a learner as a PNG image

Julia Equivalent: IAI.write_png

Arguments

  • filename: Where to save the output.
  • lnr: The learner or grid to output.
  • ...: Refer to the Julia documentation for available parameters.
iai::write_dotFunction.
write_dot(filename, lnr, ...)

Output a learner in .dot format

Julia Equivalent: IAI.write_dot

Arguments

  • filename: Where to save the output.
  • lnr: The learner or grid to output.
  • ...: Refer to the Julia documentation for available parameters.
iai::write_htmlFunction.
write_html(filename, lnr, ...)

Output a learner as an interactive browser visualization in HTML format

Julia Equivalent: IAI.write_html

Arguments

  • filename: Where to save the output.
  • lnr: The learner or grid to output.
  • ...: Refer to the Julia documentation for available parameters.
write_questionnaire(filename, lnr, ...)

Output a learner as an interactive questionnaire in HTML format

Julia Equivalent: IAI.write_questionnaire

Arguments

  • filename: Where to save the output.
  • lnr: The learner or grid to output.
  • ...: Refer to the Julia documentation for available parameters.
show_questionnaire(lnr, ...)

Show an interactive questionnaire based on a learner in default browser

Julia Equivalent: IAI.show_questionnaire

Arguments

  • lnr: The learner to visualize.
  • ...: Refer to the Julia documentation for available parameters.
iai::tree_plotFunction.
tree_plot(lnr, ...)

Specify an interactive tree visualization of a tree learner

Julia Equivalent: IAI.TreePlot

Arguments

IAI Compatibility

Requires IAI version 1.1 or higher.

iai::questionnaireFunction.
questionnaire(lnr, ...)

Specify an interactive questionnaire of a tree learner

Julia Equivalent: IAI.Questionnaire

Arguments

IAI Compatibility

Requires IAI version 1.1 or higher.

iai::multi_tree_plotFunction.
multi_tree_plot(questions)

Construct an interactive tree visualization of multiple tree learners as specified by questions

Julia Equivalent: IAI.MultiTreePlot

Arguments

IAI Compatibility

Requires IAI version 1.1 or higher.

multi_questionnaire(questions)

Construct an interactive questionnaire using multiple tree learners as specified by questions

Julia Equivalent: IAI.MultiQuestionnaire

Arguments

IAI Compatibility

Requires IAI version 1.1 or higher.

Optimal Trees

optimal_tree_classifier(...)

Learner for training Optimal Classification Trees

Julia Equivalent: IAI.OptimalTreeClassifier

Arguments

  • ...: Use keyword arguments to set parameters on the resulting learner. Refer to the Julia documentation for available parameters.
optimal_tree_regressor(...)

Learner for training Optimal Regression Trees

Julia Equivalent: IAI.OptimalTreeRegressor

Arguments

  • ...: Use keyword arguments to set parameters on the resulting learner. Refer to the Julia documentation for available parameters.
optimal_tree_survivor(...)

Learner for training Optimal Survival Trees

Julia Equivalent: IAI.OptimalTreeSurvivor

Arguments

  • ...: Use keyword arguments to set parameters on the resulting learner. Refer to the Julia documentation for available parameters.
optimal_tree_prescription_minimizer(...)

Learner for training Optimal Prescriptive Trees where the prescriptions should aim to minimize outcomes

Julia Equivalent: IAI.OptimalTreePrescriptionMinimizer

Arguments

  • ...: Use keyword arguments to set parameters on the resulting learner. Refer to the Julia documentation for available parameters.
optimal_tree_prescription_maximizer(...)

Learner for training Optimal Prescriptive Trees where the prescriptions should aim to maximize outcomes

Julia Equivalent: IAI.OptimalTreePrescriptionMaximizer

Arguments

  • ...: Use keyword arguments to set parameters on the resulting learner. Refer to the Julia documentation for available parameters.

OptImpute

iai::imputeFunction.
impute(X, ...)

Impute missing values using either a specified method or through validation

Julia Equivalent: IAI.impute

Arguments

  • X: The dataframe in which to impute missing values.
  • ...: Refer to the Julia documentation for available parameters.
iai::impute_cvFunction.
impute_cv(X, ...)

Impute missing values using cross validation

Julia Equivalent: IAI.impute_cv

Arguments

  • X: The dataframe in which to impute missing values.
  • ...: Refer to the Julia documentation for available parameters.
imputation_learner(method = "opt_knn", ...)

Generic learner for imputing missing values

Julia Equivalent: IAI.ImputationLearner

Arguments

  • method: (optional) Specifies the imputation method to use.
  • ...: Use keyword arguments to set parameters on the resulting learner. Refer to the Julia documentation for available parameters.
opt_knn_imputation_learner(...)

Learner for conducting optimal k-NN imputation

Julia Equivalent: IAI.OptKNNImputationLearner

Arguments

  • ...: Use keyword arguments to set parameters on the resulting learner. Refer to the Julia documentation for available parameters.
opt_svm_imputation_learner(...)

Learner for conducting optimal SVM imputation

Julia Equivalent: IAI.OptSVMImputationLearner

Arguments

  • ...: Use keyword arguments to set parameters on the resulting learner. Refer to the Julia documentation for available parameters.
opt_tree_imputation_learner(...)

Learner for conducting optimal tree-based imputation

Julia Equivalent: IAI.OptTreeImputationLearner

Arguments

  • ...: Use keyword arguments to set parameters on the resulting learner. Refer to the Julia documentation for available parameters.
single_knn_imputation_learner(...)

Learner for conducting heuristic k-NN imputation

Julia Equivalent: IAI.SingleKNNImputationLearner

Arguments

  • ...: Use keyword arguments to set parameters on the resulting learner. Refer to the Julia documentation for available parameters.
mean_imputation_learner(...)

Learner for conducting mean imputation

Julia Equivalent: IAI.MeanImputationLearner

Arguments

  • ...: Use keyword arguments to set parameters on the resulting learner. Refer to the Julia documentation for available parameters.
rand_imputation_learner(...)

Learner for conducting random imputation

Julia Equivalent: IAI.RandImputationLearner

Arguments

  • ...: Use keyword arguments to set parameters on the resulting learner. Refer to the Julia documentation for available parameters.

Optimal Feature Selection

optimal_feature_selection_classifier(...)

Learner for conducting Optimal Feature Selection on classification problems

Julia Equivalent: IAI.OptimalFeatureSelectionClassifier

Arguments

  • ...: Use keyword arguments to set parameters on the resulting learner. Refer to the Julia documentation for available parameters.
IAI Compatibility

Requires IAI version 1.1 or higher.

optimal_feature_selection_regressor(...)

Learner for conducting Optimal Feature Selection on regression problems

Julia Equivalent: IAI.OptimalFeatureSelectionRegressor

Arguments

  • ...: Use keyword arguments to set parameters on the resulting learner. Refer to the Julia documentation for available parameters.
IAI Compatibility

Requires IAI version 1.1 or higher.

get_prediction_constant(lnr)

Return the constant term in the prediction in the trained learner

Julia Equivalent: IAI.get_prediction_constant

Arguments

  • lnr: The learner or grid to query.
IAI Compatibility

Requires IAI version 1.1 or higher.

get_prediction_weights(lnr)

Return the weights for numeric and categoric features used for prediction in the trained learner

Julia Equivalent: IAI.get_prediction_weights

Arguments

  • lnr: The learner or grid to query.
IAI Compatibility

Requires IAI version 1.1 or higher.