MCPcopy Create free account
hub / github.com/dmlc/xgboost / interaction_values

Method interaction_values

tests/python/test_shap.py:172–182  ·  view source on GitHub ↗
(trees, x)

Source from the content-addressed store, hash-verified

170 return np.array(vals)
171
172 def interaction_values(trees, x):
173 M = len(x)
174 out = np.zeros((M + 1, M + 1))
175 for i in range(len(x)):
176 for j in range(len(x)):
177 if i != j:
178 out[i, j] = interaction_value(trees, x, i, j) / 2
179 svals = shap_values(trees, x)
180 main_effects = svals - out.sum(1)
181 out[np.diag_indices_from(out)] = main_effects
182 return out
183
184 def interaction_value(trees, x, i, j):
185 M = len(x)

Callers

nothing calls this directly

Calls 1

shap_valuesFunction · 0.85

Tested by

no test coverage detected