Influence Estimation for Gradient-Boosted Decision Trees
Project description
TreeInfluence: Influence Estimation for Gradient-Boosted Decision Trees
tree-influence is a python library that implements influence estimation for gradient-boosted decision trees (GBDTs), adapting popular techniques such as TracIn and Influence Functions to GBDTs. This library is compatible with all major GBDT frameworks including LightGBM, XGBoost, CatBoost, and SKLearn.
Installation
pip install tree-influence
Usage
Simple example using BoostIn to identify the most influential training instances to a given test instance:
import numpy as np
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from lightgbm import LGBMClassifier
from tree_influence.explainers import BoostIn
# load iris data
data = load_iris()
X, y = data['data'], data['target']
# use two classes, then split into train and test
idxs = np.where(y != 2)[0]
X, y = X[idxs], y[idxs]
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.1, random_state=1)
# train GBDT model
model = LGBMClassifier().fit(X_train, y_train)
# fit influence estimator
explainer = BoostIn().fit(model, X_train, y_train)
# estimate training influences on each test instance
influence = explainer.get_local_influence(X_test, y_test) # shape=(no. train, no. test)
# extract influence values for the first test instance
values = influence[:, 0] # shape=(no. train,)
# sort training examples from:
# - most positively influential (decreases loss of the test instance the most), to
# - most negatively influential (increases loss of the test instance the most)
training_idxs = np.argsort(values)[::-1]
Supported Estimators
tree-influence supports the following influence-estimation techniques in GBDTs:
Method | Description |
---|---|
BoostIn | Traces the influence of a training instance throughout the training process (adaptation of TracIn). |
TREX | Trains a surrogate kernel model that approximates the original model and decomposes any prediction into a weighted sum of the training examples (adaptation of representer-point methods). |
LeafInfluence | Estimates the impact of a training example on the final GBDT model (adaptation of influence functions). |
TreeSim | Computes influence via similarity in tree-kernel space. |
LOO | Leave-one-out retraining, measures the influence of a training instance by removing and retraining without that instance. |
License
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
tree-influence-0.0.3.tar.gz
(303.7 kB
view hashes)
Built Distributions
Close
Hashes for tree_influence-0.0.3-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad87deaab48b2edf1f6d344b6bb4d5a06c80efe9a0548eb043b5e3e5f66e9b1e |
|
MD5 | dd7655345e5ed2e0761a8fbba3815122 |
|
BLAKE2b-256 | 692969dbec2f57b0cb764d1e50ed3a8901d5e3ee56fcd027fc15d65460f078ef |
Close
Hashes for tree_influence-0.0.3-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42a0f15ccb6f30e11fae1c9e49659bbfea083768a2269cf048e5ef370519c6ad |
|
MD5 | e17291542e6f673bfce917a96b52bc59 |
|
BLAKE2b-256 | 9d6f946c2a29c7f6119aa3a5dcd3be51676b80189a20ba4ee455be788450d9c9 |
Close
Hashes for tree_influence-0.0.3-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 980bbeed3fc58fb1b50ee26d3224656c37b0939215a07d406f0ecd7516a7b831 |
|
MD5 | 874b317c998ce4dd6d7313a381c31b2b |
|
BLAKE2b-256 | 00a99dd14a1370ce356b5b5be2433c2e5b2ba87b09db8345bceb804d64f8e328 |
Close
Hashes for tree_influence-0.0.3-cp310-cp310-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 001575adba3974e659fd0eea6b0d41e7f2df266cbf8ade8aa2dd68c49ba4df90 |
|
MD5 | 607cf4be51ef13e21a0b1dc42324fb15 |
|
BLAKE2b-256 | 374355711afbc4fe7ab6ac244c374241a71115b2b05227ef565b469d0b04d3ea |
Close
Hashes for tree_influence-0.0.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd83b3b3395e24b11e44509a08eb746a7d5888dc8b37a74a85cb5d33d9d9ab7a |
|
MD5 | 996a53e6515966b2bc14b4d20558cfb5 |
|
BLAKE2b-256 | 2b2f085ced8b94bd7558e93ee3a5833b578e4245ca58adf929c2282f3358b3a0 |
Close
Hashes for tree_influence-0.0.3-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7ea8361460c72bb97ce87c09946cb920dd2483b2c4ac99e67dc82c25a56019cd |
|
MD5 | 333cb7e94c0383e051d0724572a5c88d |
|
BLAKE2b-256 | 8b3f73441762ddce55ba45a978aed2d146ce52047a53c8d0478901f1f7784dca |
Close
Hashes for tree_influence-0.0.3-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 01a57e6caec682559a63ccdf4057e741ec42578f5a2820b646b5bc7a5dd8a6bb |
|
MD5 | 5652f96b1b41b1e273952d852405dc24 |
|
BLAKE2b-256 | a5f0669a1b8494a8aa1fdeaade77cde46ac14b511d6daf5f04c9dd4c4d707dfb |
Close
Hashes for tree_influence-0.0.3-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6af35cb645a0e98a1daf422e5a3a72335171d447b0ed53fbe53a8d3b3996143e |
|
MD5 | 6101dad0d3cfeb304038d8355c5127d1 |
|
BLAKE2b-256 | 7569bff210e6479721bacd89dcf2dfeee2c26b3f2e65176f61f697e51cfbf4c5 |
Close
Hashes for tree_influence-0.0.3-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3270357fda06c7716078f4f18d80728de96d90cd484987814a5afd254fcfde76 |
|
MD5 | fd5f7a7a159760d92d22fe02dc223e10 |
|
BLAKE2b-256 | a95165b8c9b7ec073e746815e2c20ce5c36b056fc632376f119764290cfab44b |
Close
Hashes for tree_influence-0.0.3-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 02ea391375f1a7d2cc76605b2aabdf4a6095cd438c564f15f617e0dbbb6830db |
|
MD5 | dd00c87365baf27d387136d546279906 |
|
BLAKE2b-256 | 7c4f1839e1a4da12eff745c02ec01795f918b0c516afa7ccde6c1c8333e00d72 |
Close
Hashes for tree_influence-0.0.3-cp39-cp39-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1333fc8ec98d9782a71ee2a3ad675ef5c2614458636d0f8f2a3480203c2aef1e |
|
MD5 | 658f8f424edf5a9bffeafbb1fa1c004b |
|
BLAKE2b-256 | 6cd8b5caa807f370177778380e2d5f476aa585ad4682b0261db2d3721d8c032a |
Close
Hashes for tree_influence-0.0.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0eba17076094cc2cf78f0b97823a24954561bfeee9fbf882e3a9ae51e6fd58a |
|
MD5 | b75161f3f0265c669bd72be856f27e1c |
|
BLAKE2b-256 | ad87412dfb5f5cdc0526048f4d3d3ef143501f4e62b5e07da74eae7a609d85e3 |
Close
Hashes for tree_influence-0.0.3-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 15ea00be7fbcff7881cf32ff78b4eb38d79b538505ce083797e45497d8a32227 |
|
MD5 | adb01651fae10d08b51efbb87ef4e405 |
|
BLAKE2b-256 | 49441b7abc8b348695877e1e035b418c186ca2ce023ebc6cb2612a921fb61d58 |
Close
Hashes for tree_influence-0.0.3-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3833facc7519db4fc12a1cfd9c057068c6fd982da909543709f346c0d04b6f0c |
|
MD5 | f9d52aaabb66ecc01e26e53a1169e00b |
|
BLAKE2b-256 | 6f3e4d4a68c27e9ee986c8858296a3d4bd1ddfb731cc7103f8484a60421e3893 |