# API Reference

Documentation for the iai package

## Setup

iai::iai_setupFunction
iai_setup(...)

Initialize Julia and the IAI package.

This function is called automatically with default parameters the first time any iai function is used in an R session. If custom parameters for Julia setup are required, this function must be called in every R session before calling other iai functions.

Arguments

iai::install_juliaFunction
install_julia(version = "latest", prefix = julia_default_install_dir())

Arguments

• version: The version of Julia to install (e.g. "1.6.3"). Defaults to "latest", which will install the most recent stable release.
• prefix: The directory where Julia will be installed. Defaults to a location determined by rappdirs::user_data_dir.
iai::install_system_imageFunction
install_system_image(
version = "latest",
replace_default = F,
prefix = sysimage_default_install_dir()
)

Arguments

• version: The version of the IAI system image to install (e.g. "2.1.0"). Defaults to "latest", which will install the most recent release.
• replace_default: Whether to replace the default Julia system image with the downloaded IAI system image. Defaults to FALSE.
• prefix: The directory where the IAI system image will be installed. Defaults to a location determined by rappdirs::user_data_dir.
iai::get_machine_idFunction
get_machine_id()

Return the machine ID for the current computer.

## General Utilities

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.
IAI Compatibility

Showing a grid search requires IAI version 2.0 or higher.

## 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.

## Scoring

iai::scoreFunction
score(obj, ...)

Generic function for calculating scores

Julia Equivalent: IAI.score

Arguments

• obj: The object controlling which method is used
• ...: Arguments depending on the specific method used
iai::score.defaultFunction
score(obj, predictions, truths, ...)

Calculate the score for a set of predictions on the given data

Julia Equivalent: IAI.score

Arguments

• obj: The type of problem.
• predictions: The predictions to evaluate.
• truths: The true target values for these observations.
• ...: Other parameters, including the criterion. Refer to the Julia documentation for available parameters.
IAI Compatibility

Requires IAI version 2.1 or higher.

## 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::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.
• ...: Refer to the Julia documentation for available parameters.
iai::score.learnerFunction
score(obj, X, ...)

Calculate the score for a model on the given data

Julia Equivalent: IAI.score

Arguments

• obj: 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.
iai::variable_importanceFunction
variable_importance(lnr, ...)

Generate a ranking of the variables in the learner according to their importance during training. The results are normalized so that they sum to one.

Julia Equivalent: IAI.variable_importance

Arguments

• lnr: The learner to query.
• ...: 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(obj, ...)

Generic function for constructing an ROC curve

Julia Equivalent: IAI.ROCCurve

Arguments

• obj: The object controlling which method is used
• ...: Arguments depending on the specific method used
iai::roc_curve.learnerFunction
roc_curve(obj, X, y, ...)

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

Julia Equivalent: IAI.ROCCurve

Arguments

• obj: The learner or grid to use for prediction.
• X: The features of the data.
• y: The labels of the data.
• ...: Additional arguments (unused)
iai::roc_curve.defaultFunction
roc_curve(obj, y, positive_label = stop("positive_label is required"), ...)

Construct an ROC curve from predicted probabilities and true labels

Julia Equivalent: IAI.ROCCurve

Arguments

• obj: The predicted probabilities for each point in the data.
• y: The true labels of the data.
• positive_label: The label for which probability is being predicted.
• ...: Additional arguments (unused)
IAI Compatibility

Requires IAI version 2.0 or higher.

iai::get_roc_curve_dataFunction
get_roc_curve_data(curve)

Extract the underlying data from an ROC curve (as returned by roc_curve)

The data is returned as a list with two keys: auc giving the area-under-the-curve, and coords containing a vector of lists representing each point on the curve, each with keys fpr (the false positive rate), tpr (the true positive rate) and threshold (the threshold).

Julia Equivalent: IAI.get_roc_curve_data

Arguments

• curve: The curve to query.
IAI Compatibility

Requires IAI version 2.1 or higher.

plot.roc_curveFunction
plot(x, ...)

Plot an ROC curve

Arguments

• x: The ROC curve to plot
• ...: Additional arguments (unused)
IAI Compatibility

Requires IAI version 2.1 or higher.

### Survival learners

iai::predict_hazardFunction
predict_hazard(lnr, X, ...)

Return the fitted hazard coefficient estimate made by a model for each point in the features.

A higher hazard coefficient estimate corresponds to a smaller predicted survival time.

Julia Equivalent: IAI.predict_hazard

Arguments

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

Requires IAI version 1.2 or higher.

iai::predict_expected_survival_timeFunction
predict_expected_survival_time(lnr, X, ...)

Return the expected survival time estimate made by a model for each point in the features.

Julia Equivalent: IAI.predict_expected_survival_time

Arguments

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

Requires IAI version 2.0 or higher.

iai::get_survival_curve_dataFunction
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 and policy learners

iai::predict_outcomesFunction
predict_outcomes(lnr, X, ...)

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

Julia Equivalent: IAI.predict_outcomes (for prescription or policy learners as appropriate)

Arguments

• lnr: The learner or grid to use for prediction.
• X: The features of the data.
• ...: For policy learners only, the reward matrix.
IAI Compatibility

Requires IAI version 2.0 or higher for policy learners.

### Policy learners

iai::predict_treatment_rankFunction
predict_treatment_rank(lnr, X)

Return the treatments in ranked order of effectiveness for each point in the features

Julia Equivalent: IAI.predict_treatment_rank

Arguments

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

Requires IAI version 2.1 or higher.

iai::predict_treatment_outcomeFunction
predict_treatment_outcome(lnr, X)

Return the estimated quality of each treatment in the trained model of the learner for each point in the features

Julia Equivalent: IAI.predict_treatment_outcome

Arguments

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

Requires IAI version 2.1 or higher.

### 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.
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.

## 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.
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 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 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 to query.
• node_index: The node in the tree to query.
iai::get_split_weightsFunction
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 to query.
• node_index: The node in the tree to query.

### Classification tree learners

iai::get_classification_probaFunction
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 to query.
• node_index: The node in the tree to query.
• ...: Refer to the Julia documentation for available parameters.
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 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.

Classification tree learners also support:

### Regression tree learners

iai::get_regression_constantFunction
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 classification, regression or prescription tree learners as appropriate)

Arguments

• lnr: The learner to query.
• node_index: The node in the tree to query.
• ...: If a prescription problem, the treatment to query.
iai::get_regression_weightsFunction
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 classification, regression or prescription tree learners as appropriate)

Arguments

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

### Survival tree learners

iai::get_survival_curveFunction
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 to query.
• node_index: The node in the tree to query.
• ...: Refer to the Julia documentation for available parameters.
iai::get_survival_expected_timeFunction
get_survival_expected_time(lnr, node_index, ...)

Return the predicted expected survival time at a node of a tree

Julia Equivalent: IAI.get_survival_expected_time

Arguments

• lnr: The learner to query.
• node_index: The node in the tree to query.
• ...: Refer to the Julia documentation for available parameters.
IAI Compatibility

Requires IAI version 2.1 or higher.

iai::get_survival_hazardFunction
get_survival_hazard(lnr, node_index, ...)

Return the predicted hazard ratio at a node of a tree

Julia Equivalent: IAI.get_survival_hazard

Arguments

• lnr: The learner to query.
• node_index: The node in the tree to query.
• ...: Refer to the Julia documentation for available parameters.
IAI Compatibility

Requires IAI version 2.1 or higher.

### Prescription tree learners

Prescription tree learners also support:

### Policy tree learners

iai::get_policy_treatment_rankFunction
get_policy_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_policy_treatment_rank

Arguments

• lnr: The learner to query.
• node_index: The node in the tree to query.
• ...: Refer to the Julia documentation for available parameters.
IAI Compatibility

Requires IAI version 2.0 or higher.

iai::get_policy_treatment_outcomeFunction
get_policy_treatment_outcome(lnr, node_index, ...)

Return the quality of the treatments at a node of a tree

Julia Equivalent: IAI.get_policy_treatment_outcome

Arguments

• lnr: The learner to query.
• node_index: The node in the tree to query.
• ...: Refer to the Julia documentation for available parameters.
IAI Compatibility

Requires IAI version 2.1 or higher.

### 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 to output.
• ...: Refer to the Julia documentation for available parameters.
iai::write_pdfFunction
write_pdf(filename, lnr, ...)

Output a learner as a PDF image

Julia Equivalent: IAI.write_pdf

Arguments

• filename: Where to save the output.
• lnr: The learner to output.
• ...: Refer to the Julia documentation for available parameters.
IAI Compatibility

Requires IAI version 2.1 or higher.

iai::write_svgFunction
write_svg(filename, lnr, ...)

Output a learner as a SVG image

Julia Equivalent: IAI.write_svg

Arguments

• filename: Where to save the output.
• lnr: The learner to output.
• ...: Refer to the Julia documentation for available parameters.
IAI Compatibility

Requires IAI version 2.1 or higher.

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 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.
IAI Compatibility

Outputting a grid search requires IAI version 2.0 or higher.

iai::write_questionnaireFunction
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.
IAI Compatibility

Outputting a grid search requires IAI version 2.0 or higher.

iai::show_questionnaireFunction
show_questionnaire(lnr, ...)

Show an interactive questionnaire based on a learner in default browser

Julia Equivalent: IAI.show_questionnaire

Arguments

• lnr: The learner or grid to visualize.
• ...: Refer to the Julia documentation for available parameters.
IAI Compatibility

Showing a grid search requires IAI version 2.0 or higher.

iai::multi_tree_plotFunction
multi_tree_plot(obj, ...)

Generic function for constructing an interactive tree visualization of multiple tree learners

Julia Equivalent: IAI.MultiTreePlot

Arguments

• obj: The object controlling which method is used
• ...: Arguments depending on the specific method used
iai::multi_tree_plot.defaultFunction
multi_tree_plot(obj, ...)

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.

iai::multi_tree_plot.grid_searchFunction
multi_tree_plot(obj, ...)

Construct an interactive tree visualization of multiple tree learners from the results of a grid search

Julia Equivalent: IAI.MultiTreePlot

Arguments

• obj: The grid to visualize
• ...: Additional arguments (unused)
IAI Compatibility

Requires IAI version 2.0 or higher.

iai::multi_questionnaireFunction
multi_questionnaire(obj, ...)

Generic function for constructing an interactive questionnaire using multiple tree learners

Julia Equivalent: IAI.MultiQuestionnaire

Arguments

• obj: The object controlling which method is used
• ...: Arguments depending on the specific method used
iai::multi_questionnaire.defaultFunction
multi_questionnaire(obj, ...)

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.

### Tree Stability

iai::get_treeFunction
get_tree(lnr, index)

Return a copy of the learner that uses a specific tree rather than the tree with the best training objective.

Julia Equivalent: get_tree

Arguments

• lnr: The original learner
• index: The index of the tree to use
IAI Compatibility

Requires IAI version 2.2 or higher.

#### Stability Analysis

iai::get_stability_resultsFunction
get_stability_results(stability)

Return the trained trees in order of increasing objective value, along with their variable importance scores for each feature

Julia Equivalent: get_stability_results

Arguments

• stability: The stability analysis to query
IAI Compatibility

Requires IAI version 2.2 or higher.

iai::get_cluster_distancesFunction
get_cluster_distances(stability, num_trees)

Return the distances between the centroids of each pair of clusters, under the clustering of a given number of trees

Julia Equivalent: get_cluster_distances

Arguments

• stability: The stability analysis to query
• num_trees: The number of trees to include in the clustering
IAI Compatibility

Requires IAI version 2.2 or higher.

iai::get_cluster_assignmentsFunction
get_cluster_assignments(stability, num_trees)

Return the indices of the trees assigned to each cluster, under the clustering of a given number of trees

Julia Equivalent: get_cluster_assignments

Arguments

• stability: The stability analysis to query
• num_trees: The number of trees to include in the clustering
IAI Compatibility

Requires IAI version 2.2 or higher.

iai::get_cluster_detailsFunction
get_cluster_details(stability, num_trees)

Return the centroid information for each cluster, under the clustering of a given number of trees

Julia Equivalent: get_cluster_details

Arguments

• stability: The stability analysis to query
• num_trees: The number of trees to include in the clustering
IAI Compatibility

Requires IAI version 2.2 or higher.

plot.stability_analysisFunction
plot(x, ...)

Plot a stability analysis

Arguments

• x: The stability analysis to plot
• ...: Additional arguments (unused)
IAI Compatibility

Requires IAI version 2.2 or higher.

### Similarity Comparison

iai::variable_importance_similarityFunction
variable_importance_similarity(lnr, new_lnr, ...)

Calculate similarity between the final tree in a tree learner with all trees in new tree learner using variable importance scores.

Julia Equivalent: variable_importance_similarity

Arguments

• lnr: The original learner
• new_lnr: The new learner
• ...: Additional arguments (refer to Julia documentation)
IAI Compatibility

Requires IAI version 2.2 or higher.

iai::similarity_comparisonFunction
similarity_comparison(lnr, new_lnr, deviations)

Conduct a similarity comparison between the final tree in a learner and all trees in a new learner to consider the tradeoff between training performance and similarity to the original tree

Julia Equivalent: SimilarityComparison

Arguments

• lnr: The original learner
• new_lnr: The new learner
• deviations: The deviation between the original tree and each tree in the new learner
IAI Compatibility

Requires IAI version 2.2 or higher.

iai::get_train_errorsFunction
get_train_errors(similarity)

Extract the training objective value for each candidate tree in the comparison, where a lower value indicates a better solution

Julia Equivalent: get_train_errors

Arguments

• similarity: The similarity comparison
IAI Compatibility

Requires IAI version 2.2 or higher.

plot.similarity_comparisonFunction
plot(x, ...)

Plot a similarity comparison

Arguments

• x: The similarity comparison to plot
• ...: Additional arguments (unused)
IAI Compatibility

Requires IAI version 2.2 or higher.

## Optimal Trees

iai::optimal_tree_policy_minimizerFunction
optimal_tree_policy_minimizer(...)

Learner for training Optimal Policy Trees where the policy should aim to minimize outcomes

Julia Equivalent: IAI.OptimalTreePolicyMinimizer

Arguments

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

Requires IAI version 2.0 or higher.

iai::optimal_tree_policy_maximizerFunction
optimal_tree_policy_maximizer(...)

Learner for training Optimal Policy Trees where the policy should aim to maximize outcomes

Julia Equivalent: IAI.OptimalTreePolicyMaximizer

Arguments

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

Requires IAI version 2.0 or higher.

iai::refit_leavesFunction
refit_leaves(lnr, ...)

Refit the models in the leaves of a trained learner using the supplied data

Julia Equivalent: refit_leaves!

Arguments

• lnr: The learner to refit
• ...: Refer to the Julia documentation for available parameters
IAI Compatibility

Requires IAI version 3.0 or higher.

iai::copy_splits_and_refit_leavesFunction
copy_splits_and_refit_leaves(new_lnr, orig_lnr, ...)

Copy the tree split structure from one learner into another and refit the models in each leaf of the tree using the supplied data

Julia Equivalent: copy_splits_and_refit_leaves!

Arguments

• new_lnr: The learner to modify and refit
• orig_lnr: The learner from which to copy the tree split structure
• ...: Refer to the Julia documentation for available parameters
IAI Compatibility

Requires IAI version 3.0 or higher.

iai::prune_treesFunction
prune_trees(lnr, ...)

Use the trained trees in a learner along with the supplied validation data to determine the best value for the cp parameter and then prune the trees according to this value

Julia Equivalent: prune_trees!

Arguments

• lnr: The learner to prune
• ...: Refer to the Julia documentation for available parameters
IAI Compatibility

Requires IAI version 3.0 or higher.

## OptImpute

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

Impute missing values using either a specified method or through validation

Julia Equivalent: IAI.impute

This function was deprecated in iai 1.7.0. This is for consistency with the IAI v3.0.0 Julia release.

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

This function was deprecated in iai 1.7.0. This is for consistency with the IAI v3.0.0 Julia release.

Arguments

• X: The dataframe in which to impute missing values.
• ...: Refer to the Julia documentation for available parameters.
iai::imputation_learnerFunction
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.
iai::zero_imputation_learnerFunction
zero_imputation_learner(...)

Learner for conducting zero-imputation

Julia Equivalent: IAI.ZeroImputationLearner

Arguments

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

Requires IAI version 3.0 or higher.

iai::fit_and_expandFunction
fit_and_expand(lnr, X, ...)

Fit an imputation learner with training features and create adaptive indicator features to encode the missing pattern

Julia Equivalent: IAI.fit_and_expand!

Arguments

• lnr: The learner to use for imputation.
• X: The dataframe in which to impute missing values.
• ...: Refer to the Julia documentation for available parameters.
IAI Compatibility

Requires IAI version 3.0 or higher.

iai::transform_and_expandFunction
transform_and_expand(lnr, X, ...)

Transform features with a trained imputation learner and create adaptive indicator features to encode the missing pattern

Julia Equivalent: IAI.transform_and_expand

Arguments

• lnr: The learner to use for imputation.
• X: The dataframe in which to impute missing values.
• ...: Refer to the Julia documentation for available parameters.
IAI Compatibility

Requires IAI version 3.0 or higher.

## Optimal Feature Selection

iai::get_prediction_constantFunction
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 to query.
• ...: If a GLMNet learner, the index of the fit in the path to query, defaulting to the best fit if not supplied.
IAI Compatibility

Requires IAI version 1.1 or higher.

iai::get_prediction_weightsFunction
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 to query.
• ...: If a GLMNet learner, the index of the fit in the path to query, defaulting to the best fit if not supplied.
IAI Compatibility

Requires IAI version 1.1 or higher.

ggplot2::autoplot.grid_searchFunction
ggplot2::autoplot(x, type = stop("type is required"), ...)

Construct a ggplot2::ggplot object plotting grid search results for Optimal Feature Selection learners

Arguments

• x: The grid search to plot
• type: The type of plot to construct (either "validation" or "importance", for more information refer to the Julia documentation for plotting grid search results )
• ...: Additional arguments (unused)
IAI Compatibility

Requires IAI version 2.2 or higher.

## Reward Estimation

iai::fit_predictFunction
fit_predict(lnr, X, treatments, ...)

Fit a reward estimation model on features, treatments and outcomes and return predicted counterfactual rewards for each observation, as well as the score of the internal estimators.

For categorical treatments, returns the estimated reward under each treatment observed in the data. For numeric treatments, returns the estimated reward under each treatment candidate.

Julia Equivalent: IAI.fit_predict!

Arguments

• lnr: The learner or grid to use for estimation
• X: The features of the data.
• treatments: The treatment applied to each point in the data.
• ...: Additional arguments depending on the treatment and outcome types. Refer to the Julia documentation for more information.
iai::predict_rewardFunction
predict_reward(lnr, ...)

Return counterfactual rewards estimated using learner parameters for each observation in the supplied data and predictions

Julia Equivalent: IAI.predict_reward

Arguments

• lnr: The learner or grid to use for estimation
• ...: Additional arguments depending on the treatment and outcome types. Refer to the Julia documentation for more information.
IAI Compatibility

Requires IAI version 3.0 or higher.

### Categorical Treatments

iai::categorical_classification_reward_estimatorFunction
categorical_classification_reward_estimator(...)

Learner for conducting reward estimation with categorical treatments and classification outcomes

Julia Equivalent: IAI.CategoricalClassificationRewardEstimator

Arguments

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

Requires IAI version 2.2 or higher.

iai::categorical_regression_reward_estimatorFunction
categorical_regression_reward_estimator(...)

Learner for conducting reward estimation with categorical treatments and regression outcomes

Julia Equivalent: IAI.CategoricalRegressionRewardEstimator

Arguments

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

Requires IAI version 2.2 or higher.

iai::categorical_survival_reward_estimatorFunction
categorical_survival_reward_estimator(...)

Learner for conducting reward estimation with categorical treatments and survival outcomes

Julia Equivalent: IAI.CategoricalSurvivalRewardEstimator

Arguments

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

Requires IAI version 2.2 or higher.

iai::equal_propensity_estimatorFunction
equal_propensity_estimator(...)

Learner that estimates equal propensity for all treatments.

For use with data from randomized experiments where treatments are known to be randomly assigned.

Julia Equivalent: IAI.EqualPropensityEstimator

Arguments

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

Requires IAI version 2.1 or higher.

### Numeric Treatments

iai::numeric_classification_reward_estimatorFunction
numeric_classification_reward_estimator(...)

Learner for conducting reward estimation with numeric treatments and classification outcomes

Julia Equivalent: IAI.NumericClassificationRewardEstimator

Arguments

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

Requires IAI version 2.2 or higher.

iai::get_estimation_densitiesFunction
get_estimation_densities(lnr, ...)

Return the total kernel density surrounding each treatment candidate for the propensity/outcome estimation problems in a fitted learner.

Julia Equivalent: IAI.get_estimation_densities

Arguments

• lnr: The learner from which to extract densities
• ...: Refer to the Julia documentation for other parameters
IAI Compatibility

Requires IAI version 2.2 or higher.

iai::tune_reward_kernel_bandwidthFunction
tune_reward_kernel_bandwidth(lnr, ...)

Conduct the reward kernel bandwidth tuning procedure for a range of starting bandwidths and return the final tuned values.

Julia Equivalent: IAI.tune_reward_kernel_bandwidth

Arguments

• lnr: The learner to use for tuning the bandwidth
• ...: Refer to the Julia documentation for other parameters
IAI Compatibility

Requires IAI version 2.2 or higher.

iai::set_reward_kernel_bandwidthFunction
set_reward_kernel_bandwidth(lnr, ...)

Save a new reward kernel bandwidth inside a learner, and return new reward predictions generated using this bandwidth for the original data used to train the learner.

Julia Equivalent: IAI.set_reward_kernel_bandwidth!

Arguments

• lnr: The learner to modify
• ...: Refer to the Julia documentation for available parameters.
IAI Compatibility

Requires IAI version 2.2 or higher.

## Heuristics

### Random Forests

iai::random_forest_classifierFunction
random_forest_classifier(...)

Learner for training random forests for classification problems

Julia Equivalent: IAI.RandomForestClassifier

Arguments

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

Requires IAI version 2.1 or higher.

iai::random_forest_regressorFunction
random_forest_regressor(...)

Learner for training random forests for regression problems

Julia Equivalent: IAI.RandomForestRegressor

Arguments

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

Requires IAI version 2.1 or higher.

### XGBoost

iai::xgboost_classifierFunction
xgboost_classifier(...)

Learner for training XGBoost models for classification problems

Julia Equivalent: IAI.XGBoostClassifier

Arguments

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

Requires IAI version 2.1 or higher.

iai::xgboost_regressorFunction
xgboost_regressor(...)

Learner for training XGBoost models for regression problems

Julia Equivalent: IAI.XGBoostRegressor

Arguments

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

Requires IAI version 2.1 or higher.

iai::xgboost_survival_learnerFunction
xgboost_survival_learner(...)

Learner for training XGBoost models for survival problems

Julia Equivalent: IAI.XGBoostSurvivalLearner

Arguments

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

Requires IAI version 2.2 or higher.

iai::predict_shapFunction
predict_shap(lnr, X)

Calculate SHAP values for all points in the features using the learner

Julia Equivalent: IAI.predict_shap

Arguments

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

Requires IAI version 2.2 or higher.

iai::write_boosterFunction
write_booster(filename, lnr)

Write the internal booster saved in the learner to file

Julia Equivalent: IAI.write_booster

Arguments

• filename: Where to save the output.
• lnr: The XGBoost learner with the booster to output.
IAI Compatibility

Requires IAI version 2.1 or higher.

### GLMNet

iai::glmnetcv_classifierFunction
glmnetcv_classifier(...)

Learner for training GLMNet models for classification problems with cross-validation

Julia Equivalent: IAI.GLMNetCVClassifier

Arguments

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

Requires IAI version 2.3 or higher.

iai::glmnetcv_regressorFunction
glmnetcv_regressor(...)

Learner for training GLMNet models for regression problems with cross-validation

Julia Equivalent: IAI.GLMNetCVRegressor

Arguments

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

Requires IAI version 2.1 or higher.

iai::glmnetcv_survival_learnerFunction
glmnetcv_survival_learner(...)

Learner for training GLMNet models for survival problems with cross-validation

Julia Equivalent: IAI.GLMNetCVSurvivalLearner

Arguments

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

Requires IAI version 3.0 or higher.

iai::get_num_fitsFunction
get_num_fits(lnr)

Return the number of fits along the path in the trained learner

Julia Equivalent: IAI.get_num_fits

Arguments

• lnr: The GLMNet learner to query.
IAI Compatibility

Requires IAI version 2.1 or higher.