API Reference

Documentation for the Heuristics public interface.

Index

Random Forest

XGBoost

IAI.predict_shapFunction
predict_shap(lnr::XGBoostLearner, X::FeatureInput)

Calculate SHAP values for all points in the features X using lnr.

Returns a Dict with the following keys:

  • :shap_values: A Matrix of SHAP values for each sample and feature in X. For classification problems, this key contains a Vector of such matrices, one for each target label.
  • :expected_value: A Float64 containing the expected value for use in SHAP analysis. For classification problems, this key contains a Vector of such values, one for each target label.
  • :features: A DataFrame containing the features X in the appropriate format to pass to SHAP visualization functions.
  • :labels: A Vector giving the order of the target labels in the problem, corresponding to the order of the results in :shap_values and :expected_value (for classification problems only)

These calculations are analogous to the following Python code:

import shap
explainer = shap.TreeExplainer(lnr)
shap_values = explainer.shap_values(X)
expected_value = explainer.expected_value
IAI.write_boosterFunction
write_booster(filepath, lnr::XGBoostLearner)

Write the internal booster saved in lnr to filepath.

This can be used to open the trained XGBoost model using the XGBoost Python wrapper in order to conduct a SHAP analysis.

If filepath ends in ".json" the booster will be written in JSON format, otherwise an internal XGBoost binary format is used.

Warning

This output file cannot be loaded back into the IAI interface. Use write_json to save the entire learner if you want to be able to read it back in future.

GLMNet

IAI.get_num_fitsMethod
get_num_fits(lnr::GLMNetCVRegressor)

Returns the number of fits along the path in lnr.

IAI.predictMethod
predict(lnr::GLMNetCVRegressor, X::FeatureInput)

Returns the prediction made by the best fit on the path for lnr for each point in the data X.


predict(lnr::GLMNetCVRegressor, X::FeatureInput, fit_index::Integer)

Returns the prediction made by the fit at fit_index on the path for lnr for each point in the data X.

IAI.scoreMethod
score(lnr::GLMNetCVRegressor, X::FeatureInput, y::TargetInput...;
      keyword_arguments...)

Calculates the score for the best fit on the path for lnr on data X and y.


score(lnr::GLMNetCVRegressor, X::FeatureInput, y::TargetInput...;
      fit_index::Integer, keyword_arguments...)

Calculates the score for the fit at fit_index on the path for lnr on data X and y.

IAI.get_prediction_weightsMethod
get_prediction_weights(lnr::GLMNetCVRegressor)

Return the weights for each feature in the prediction made by the best fit on the path in lnr.


get_prediction_weights(lnr::GLMNetCVRegressor, fit_index::Integer)

Return the weights for each feature in the prediction made by the fit at fit_index on the path in lnr.

IAI.get_prediction_constantMethod
get_prediction_constant(lnr::GLMNetCVRegressor)

Return the constant term in the prediction made by the best fit on the path in lnr.


get_prediction_constant(lnr::GLMNetCVRegressor, fit_index::Integer)

Return the constant term in the prediction made by the fit at fit_index on the path in lnr.