api documentation

Trees

export_tree_data()

Export tree data from model.

TabularTrees(trees, get_root_node_given_tree)

Generic tree structure in tabular format.

LightGBM

LightGBMTabularTrees(data)

Class to hold the LightGBM trees in tabular format.

EditableBooster(header, trees, bottom_rows)

Editable LightGBM booster.

BoosterHeader(header, version, num_class, ...)

Dataclass for the metadata in header section of a Booster.

BoosterTree(tree, num_leaves, num_cat, ...)

Data class for individual LightGBM trees.

BoosterString(rows)

String version of a LightGBM Booster.

Scikit-Learn

ScikitLearnTabularTrees(data)

Scikit-Learn GradientBoosting trees in tabular format.

ScikitLearnHistTabularTrees(data)

Scikit-Learn HistGradientBoosting trees in tabular format.

XGBoost

XGBoostTabularTrees(data)

Class to hold the XGBoost trees in tabular format.

XGBoostParser(model[, reader])

Class that dumps an xgboost Booster then parses the dumped file.

ParsedXGBoostTabularTrees(data)

Dataclass for XGBoost models that have been parsed from a model dump.

Warning

The XGBoostParser is depreceated, Booster.trees_to_dataframe can be used instead to extract tree data from a Booster object.

Explain

decompose_prediction(tabular_trees, row)

Decompose prediction from tree based model with Saabas method[1].

PredictionDecomposition(summary, nodes)

Prediction decomposition results.

calculate_shapley_values(tabular_trees, row)

Calculate shapley values from TabularTrees model for row of data.

ShapleyValues(summary, permutations)

Shapley values results.

Warning

The calculate_shapley_values function is very slow and is only implemeneted for illustration purposes.

Both xgboost and lightgbm implement the must faster treeSHAP algorithm, accessible via the Booster.predict methods when specifying pred_contribs or pred_contrib respectively.

Validate

validate_monotonic_constraints(...[, ...])

Validate that trees conform to monotonic constraints.

MonotonicConstraintResults(summary, ...)

Results of checking monotonic constraints.