(trees, x)
| 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) |
nothing calls this directly
no test coverage detected