Skip to content

Commit c886cbd

Browse files
Anton BjörklundAggrathon
Anton Björklund
authored andcommitted
order by absolute coefficient in plot
1 parent d043a24 commit c886cbd

File tree

2 files changed

+51
-48
lines changed

2 files changed

+51
-48
lines changed

examples/1_tabular_explanation.ipynb

+41-39
Large diffs are not rendered by default.

slise/plot.py

+10-9
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ def plot_dist(
352352
model = np.concatenate((np.zeros(1, model.dtype), model))
353353
alpha = np.concatenate((np.zeros(1, model.dtype), alpha))
354354
variables[0] = ""
355-
order = get_explanation_order(alpha, True)
355+
order = get_explanation_order(np.abs(alpha), True)
356356
model = model[order]
357357
alpha = alpha[order]
358358
if impact is not None:
@@ -405,14 +405,15 @@ def fill_density(ax, X, x, n):
405405

406406
# Bar plots
407407
def text(x, y, v):
408-
axbig.text(
409-
x,
410-
y,
411-
f"{v:.{decimals}f}",
412-
ha="center",
413-
va="center",
414-
bbox=dict(boxstyle="square", fc="white"),
415-
)
408+
if v != 0:
409+
axbig.text(
410+
x,
411+
y,
412+
f"{v:.{decimals}f}",
413+
ha="center",
414+
va="center",
415+
bbox=dict(boxstyle="round", fc="white", ec="grey", alpha=0.75),
416+
)
416417

417418
gs = axs[0, 1].get_gridspec()
418419
for ax in axs[:, 1]:

0 commit comments

Comments
 (0)