API Reference

API Reference

Documentation for the interpretableai package

Index

General Utilities

installFunction.

Install Julia packages required for interpretableai.iai.

set_julia_seedFunction.
set_julia_seed(seed)

Set the random seed in Julia to seed.

Julia Equivalent: Random.seed!

read_jsonFunction.
read_json(filename)

Read in a learner or grid saved in JSON format from filename.

Julia Equivalent: IAI.read_json

get_rich_output_params()

Return the current global rich output parameter settings.

Julia Equivalent: IAI.get_rich_output_params

set_rich_output_paramFunction.
set_rich_output_param(key, value)

Sets the global rich output parameter key to value.

Julia Equivalent: IAI.set_rich_output_param!

delete_rich_output_param(key)

Delete the global rich output parameter key.

Julia Equivalent: IAI.delete_rich_output_param!

Data Preparation

MixedDataType.
MixedData(values, ordinal_levels=None)

Represents a mixed data feature

MixedData features can represent a feature with either numeric/categoric or ordinal/categoric values.

Parameters

  • values: (list-like) The values of the mixed feature. In a numeric/categoric mix, all numeric elements will be treated as numeric and all remaining elements as categoric. In an ordinal/categoric mix, all elements belonging to the ordinal_levels will be treated as ordinal, and all remaining elements as categoric.
  • ordinal_levels: (Index-like, optional) If not supplied, the feature is treated as a numeric/categoric mix. If supplied, these are the ordered levels of the ordinal values in the ordinal/categoric mix.
split_dataFunction.
split_data(task, X, *y, **kwargs)

Split the data (X and y) into a tuple of training and testing data, (X_train, y_train), (X_test, y_test), for a problem of type task.

Julia Equivalent: IAI.split_data

Learners

Learner

LearnerType.

Abstract type encompassing all learners

fitFunction.
lnr.fit(X, *y, sample_weight=None)

Fits a model using the parameters in learner and the data X and y.

Julia Equivalent: IAI.fit!

Parameters

Refer to the documentation on data preparation for information on how to format and supply the data.

set_paramsFunction.
lnr.set_params(**kwargs)

Set all supplied parameters on learner.

Julia Equivalent: IAI.set_params!

get_paramsFunction.
lnr.get_params()

Return the value of all learner parameters.

Julia Equivalent: IAI.get_params

cloneFunction.
lnr.clone()

Return an unfitted copy of the learner with the same parameters.

Julia Equivalent: IAI.clone

write_jsonFunction.
obj.write_json(filename, **kwargs)

Write learner or grid to filename in JSON format.

Julia Equivalent: IAI.write_json

SupervisedLearner

Abstract type encompassing all learners for supervised tasks

predictFunction.
lnr.predict(X)

Return the predictions made by the learner for each point in the features X.

Julia Equivalent: IAI.predict

scoreFunction.
lnr.score(X, *y, **kwargs)

Calculates the score for the learner on data X and y.

Julia Equivalent: IAI.score

UnsupervisedLearner

Abstract type encompassing all learners for unsupervised tasks

ClassificationLearner

Abstract type encompassing all learners for classification tasks

predict_probaFunction.
lnr.predict_proba(X)

Return the probabilities of class membership predicted by the learner for each point in the features X.

Julia Equivalent: IAI.predict_proba

RegressionLearner

Abstract type encompassing all learners for regression tasks

SurvivalLearner

SurvivalLearnerType.

Abstract type encompassing all learners for survival tasks

predict_hazardFunction.
lnr.predict_hazard(X)

Return the fitted hazard coefficient estimate made by the learner for each point in the data X.

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

Julia Equivalent: IAI.predict_hazard

IAI Compatibility

Requires IAI version 1.2 or higher.

PrescriptionLearner

Abstract type encompassing all learners for prescription tasks

predict_outcomesFunction.
lnr.predict_outcomes(X)

Return the the predicted outcome for each treatment made by the learner for each point in the features X.

Julia Equivalent: IAI.predict_outcomes

ImputationLearner

ImputationLearner(method='opt_knn', **kwargs)

Abstract type containing all imputation learners.

Julia Equivalent: IAI.ImputationLearner

Parameters

Can be used to construct instances of imputation learners using the method keyword argument.

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

transformFunction.
lnr.transform(X)

Impute missing values in X using the fitted imputation model in lnr.

Julia Equivalent: IAI.transform

Parameters

Refer to the documentation on data preparation for information on how to format and supply the data.

fit_transformFunction.
lnr.fit_transform(X, **kwargs)

Fit the imputation learner using the training data X and impute the missing values in the training data.

Similar to calling fit followed by transform.

Julia Equivalent: IAI.fit_transform!

Parameters

Refer to the documentation on data preparation for information on how to format and supply the data.

GridSearch

GridSearchType.
GridSearch(lnr, params)

Controls grid search over parameter combinations in params for lnr.

Julia Equivalent: IAI.GridSearch

fit_cvFunction.
grid.fit_cv(X, *y, **kwargs)

Fit a grid with data X and y using k-fold cross-validation.

Julia Equivalent: IAI.fit_cv!

Parameters

Refer to the documentation on data preparation for information on how to format and supply the data.

fit_transform_cvFunction.
grid.fit_transform_cv(X, **kwargs)

For imputation learners, fit a grid with features X using k-fold cross-validation and impute missing values in X.

Julia Equivalent: IAI.fit_transform_cv!

Parameters

Refer to the documentation on data preparation for information on how to format and supply the data.

get_learnerFunction.
grid.get_learner()

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

Julia Equivalent: IAI.get_learner

get_best_paramsFunction.
grid.get_best_params()

Return the best parameter combination from the grid.

Julia Equivalent: IAI.get_best_params

get_grid_resultsFunction.
grid.get_grid_results()

Return a summary of the results from the grid search.

Julia Equivalent: IAI.get_grid_results

Tree Learners

TreeLearner

TreeLearnerType.

Abstract type encompassing all tree-based learners.

applyFunction.
lnr.apply(X)

Return the leaf index in the learner into which each point in the features X falls.

Julia Equivalent: IAI.apply

apply_nodesFunction.
lnr.apply_nodes(X)

Return the indices of the points in the features X that fall into each node in the learner.

Julia Equivalent: IAI.apply_nodes

decision_pathFunction.
lnr.decision_path(X)

Return a matrix where entry (i, j) is True if the ith point in the features X passes through the jth node in the learner.

Julia Equivalent: IAI.decision_path

print_pathFunction.
lnr.print_path(X)

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

Julia Equivalent: IAI.print_path

variable_importanceFunction.
lnr.variable_importance()

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

Julia Equivalent: IAI.variable_importance

get_num_nodesFunction.
lnr.get_num_nodes(node_index)

Return the number of nodes in the trained learner.

Julia Equivalent: IAI.get_num_nodes

get_depthFunction.
lnr.get_depth(node_index)

Return the depth of node node_index in the trained learner.

Julia Equivalent: IAI.get_depth

get_parentFunction.
lnr.get_parent(node_index)

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

Julia Equivalent: IAI.get_parent

get_lower_childFunction.
lnr.get_lower_child(node_index)

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

Julia Equivalent: IAI.get_lower_child

get_upper_childFunction.
lnr.get_upper_child(node_index)

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

Julia Equivalent: IAI.get_upper_child

get_num_samplesFunction.
lnr.get_num_samples(node_index)

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

Julia Equivalent: IAI.get_num_samples

is_categoric_splitFunction.
lnr.is_categoric_split(node_index)

Return True if node node_index in the trained learner is a categoric split.

Julia Equivalent: IAI.is_categoric_split

is_hyperplane_splitFunction.
lnr.is_hyperplane_split(node_index)

Return True if node node_index in the trained learner is a hyperplane split.

Julia Equivalent: IAI.is_hyperplane_split

is_leafFunction.
lnr.is_leaf(node_index)

Return True if node node_index in the trained learner is a leaf.

Julia Equivalent: IAI.is_leaf

lnr.is_mixed_ordinal_split(node_index)

Return True if node node_index in the trained learner is a mixed categoric/ordinal split.

Julia Equivalent: IAI.is_mixed_ordinal_split

lnr.is_mixed_parallel_split(node_index)

Return True if node node_index in the trained learner is a mixed categoric/parallel split.

Julia Equivalent: IAI.is_mixed_parallel_split

is_ordinal_splitFunction.
lnr.is_ordinal_split(node_index)

Return True if node node_index in the trained learner is an ordinal split.

Julia Equivalent: IAI.is_ordinal_split

is_parallel_splitFunction.
lnr.is_parallel_split(node_index)

Return True if node node_index in the trained learner is a parallel split.

Julia Equivalent: IAI.is_parallel_split

get_split_categoriesFunction.
lnr.get_split_categories(node_index)

Return the categoric/ordinal information used in the split at node node_index in the trained learner.

Julia Equivalent: IAI.get_split_categories

get_split_featureFunction.
lnr.get_split_feature(node_index)

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

Julia Equivalent: IAI.get_split_feature

get_split_thresholdFunction.
lnr.get_split_threshold(node_index)

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

Julia Equivalent: IAI.get_split_threshold

get_split_weightsFunction.
lnr.get_split_weights(node_index)

Return the weights for numeric and categoric features used in the hyperplane split at node node_index in the trained learner.

Julia Equivalent: IAI.get_split_weights

missing_goes_lowerFunction.
lnr.missing_goes_lower(node_index)

Return True if missing values take the lower branch at node node_index in the trained learner.

Julia Equivalent: IAI.missing_goes_lower

write_pngFunction.
lnr.write_png(filename, **kwargs)

Write learner to filename as a PNG image.

Requires GraphViz be installed and on the system PATH.

Julia Equivalent: IAI.write_png

write_dotFunction.
lnr.write_dot(filename, **kwargs)

Write learner to filename in .dot format.

Julia Equivalent: IAI.write_dot

write_htmlFunction.
lnr.write_html(filename, **kwargs)

Write interactive browser visualization of learner to filename as HTML.

Julia Equivalent: IAI.write_html

show_in_browserFunction.
lnr.show_in_browser(**kwargs)

Show interactive visualization of learner in default browser.

Julia Equivalent: IAI.show_in_browser

write_questionnaireFunction.
lnr.write_questionnaire(filename, **kwargs)

Write interactive questionnaire based on learner to filename as HTML.

Julia Equivalent: IAI.write_questionnaire

show_questionnaireFunction.
lnr.show_questionnaire(**kwargs)

Show interactive questionnaire based on learner in default browser.

Julia Equivalent: IAI.show_questionnaire

ClassificationTreeLearner

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

lnr.get_classification_label(node_index)

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

Julia Equivalent: IAI.get_classification_label

lnr.get_classification_proba(node_index)

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

Julia Equivalent: IAI.get_classification_proba

set_thresholdFunction.
lnr.set_threshold(label, threshold, simplify=False)

For a binary classification problem, update the the predicted labels in the leaves of the learner to predict label only if the predicted probability is at least threshold. If simplify is True, the tree will be simplified after all changes have been made.

Julia Equivalent: IAI.set_threshold!

set_display_labelFunction.
lnr.set_display_label(display_label)

Show the probability of display_label when visualizing learner.

Julia Equivalent: IAI.set_display_label!

reset_display_labelFunction.
lnr.reset_display_label(display_label)

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

Julia Equivalent: IAI.reset_display_label!

RegressionTreeLearner

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

lnr.get_regression_constant(node_index)

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

Julia Equivalent: IAI.get_regression_constant

lnr.get_regression_weights(node_index)

Return the weights for each feature in the regression prediction at node node_index in the trained learner.

Julia Equivalent: IAI.get_regression_weights

SurvivalTreeLearner

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

get_survival_curveFunction.
lnr.get_survival_curve(node_index)

Return the SurvivalCurve at node node_index in the trained learner.

Julia Equivalent: IAI.get_survival_curve

PrescriptionTreeLearner

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

lnr.get_prescription_treatment_rank(node_index)

Return the treatments ordered from most effective to least effective at node node_index in the trained learner.

Julia Equivalent: IAI.get_prescription_treatment_rank

lnr.get_regression_constant(node_index, treatment)

Return the constant in the regression prediction for treatment at node node_index in the trained learner.

Julia Equivalent: IAI.get_regression_constant

lnr.get_regression_weights(node_index, treatment)

Return the weights for each feature in the regression prediction for treatment at node node_index in the trained learner.

Julia Equivalent: IAI.get_regression_weights

Tree learner visualization

Abstract type encompassing objects related to visualization.

write_htmlFunction.
treeplot.write_html(filename, **kwargs)

Write interactive browser visualization to filename as HTML.

Julia Equivalent: IAI.write_html

show_in_browserFunction.
treeplot.show_in_browser(**kwargs)

Show interactive visualization in default browser.

Julia Equivalent: IAI.show_in_browser

TreePlotType.
TreePlot(lnr, **kwargs)

Specify an interactive tree visualization of lnr.

Julia Equivalent: IAI.TreePlot

Parameters

Refer to the Julia documentation on advanced tree visualization for available parameters.

IAI Compatibility

Requires IAI version 1.1 or higher.

QuestionnaireType.
Questionnaire(lnr, **kwargs)

Specify an interactive questionnaire of lnr.

Julia Equivalent: IAI.Questionnaire

Parameters

Refer to the Julia documentation on advanced tree visualization for available parameters.

IAI Compatibility

Requires IAI version 1.1 or higher.

MultiTreePlotType.
MultiTreePlot(questions)

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

Julia Equivalent: IAI.MultiTreePlot

Parameters

The questions to visualize. Refer to the documentation on advanced tree visualization for more information.

IAI Compatibility

Requires IAI version 1.1 or higher.

MultiQuestionnaire(questions)

Specify an interactive questionnaire of multiple tree learners as specified by questions

Julia Equivalent: IAI.MultiQuestionnaire

Parameters

The questions to visualize. Refer to the documentation on advanced tree visualization for more information.

IAI Compatibility

Requires IAI version 1.1 or higher.

Optimal Trees

Abstract type encompassing all optimal tree learners.

OptimalTreeClassifier(**kwargs)

Learner for training Optimal Classification Trees.

Julia Equivalent: IAI.OptimalTreeClassifier

Parameters

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

OptimalTreeRegressor(**kwargs)

Learner for training Optimal Regression Trees.

Julia Equivalent: IAI.OptimalTreeRegressor

Parameters

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

OptimalTreeSurvivor(**kwargs)

Learner for training Optimal Survival Trees.

Julia Equivalent: IAI.OptimalTreeSurvivor

Parameters

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

OptimalTreePrescriptionMinimizer(**kwargs)

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

Julia Equivalent: IAI.OptimalTreePrescriptionMinimizer

Parameters

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

OptimalTreePrescriptionMaximizer(**kwargs)

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

Julia Equivalent: IAI.OptimalTreePrescriptionMaximizer

Parameters

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

OptImpute

imputeFunction.
impute(X, *args, **kwargs)

Impute the missing values in X using either a specified method or through grid search validation.

Julia Equivalent: IAI.impute

Parameters

Refer to the Julia documentation for available parameters.

impute_cvFunction.
impute_cv(X, *args, **kwargs)

Impute the missing values in X using cross validation.

Julia Equivalent: IAI.impute_cv

Parameters

Refer to the Julia documentation for available parameters.

OptKNNImputationLearner(**kwargs)

Learner for conducting optimal k-NN imputation.

Julia Equivalent: IAI.OptKNNImputationLearner

Parameters

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

OptSVMImputationLearner(**kwargs)

Learner for conducting optimal SVM imputation.

Julia Equivalent: IAI.OptSVMImputationLearner

Parameters

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

OptTreeImputationLearner(**kwargs)

Learner for conducting optimal tree-based imputation.

Julia Equivalent: IAI.OptTreeImputationLearner

Parameters

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

SingleKNNImputationLearner(**kwargs)

Learner for conducting heuristic k-NN imputation.

Julia Equivalent: IAI.SingleKNNImputationLearner

Parameters

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

MeanImputationLearner(**kwargs)

Learner for conducting mean imputation.

Julia Equivalent: IAI.MeanImputationLearnerer

Parameters

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

RandImputationLearner(**kwargs)

Learner for conducting random imputation.

Julia Equivalent: IAI.RandImputationLearnerer

Parameters

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

Optimal Feature Selection

Abstract type encompassing all Optimal Feature Selection learners.

OptimalFeatureSelectionClassifier(**kwargs)

Learner for conducting Optimal Feature Selection on classification problems.

Julia Equivalent: IAI.OptimalFeatureSelectionClassifier

Parameters

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.

OptimalFeatureSelectionRegressor(**kwargs)

Learner for conducting Optimal Feature Selection on regression problems.

Julia Equivalent: IAI.OptimalFeatureSelectionRegressor

Parameters

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.

lnr.get_prediction_constant()

Return the constant term in the prediction in the trained learner.

Julia Equivalent: IAI.get_prediction_constant

IAI Compatibility

Requires IAI version 1.1 or higher.

lnr.get_prediction_weights()

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

Julia Equivalent: IAI.get_prediction_weights

IAI Compatibility

Requires IAI version 1.1 or higher.

Miscellaneous Types

ROCCurve

ROCCurveType.
ROCCurve(lnr, X, y)

Construct an ROC curve using trained lnr on the features X and labels y.

Contains the following fields:

  • coords: a dict for each point on the curve with the following keys: - 'fpr': false positive rate at the given threshold - 'tpr': true positve rate at the given threshold - 'threshold': the threshold
  • auc: the area-under-the-curve (AUC)

Julia Equivalent: IAI.ROCCurve

show_in_browserFunction.
curve.show_in_browser()

Visualize the ROC curve in the browser.

Julia Equivalent: IAI.show_in_browser

SurvivalCurve

SurvivalCurveType.

Container for survival curve information.

Use curve[t] to get the survival probability prediction from curve at time t.

get_dataFunction.
curve.get_data()

Extract the underlying data from the curve as a dict with two keys:

  • 'times': the time for each breakpoint on the curve
  • 'coefs': the probablility for each breakpoint on the curve

Julia Equivalent: IAI.get_survival_curve_data