Skip to content

Commit 61970ab

Browse files
committed
fix issue #274
1 parent 75bf9f4 commit 61970ab

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

python/interpret-core/interpret/data/_response.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -449,14 +449,13 @@ def visualize(self, key=None):
449449
if key is None:
450450
y = data_dict["y"]
451451
values, counts = np.unique(y, return_counts=True)
452-
trace1 = go.Bar(x=[values[0]], y=[counts[0]])
453-
trace2 = go.Bar(x=[values[1]], y=[counts[1]])
452+
traces = [go.Bar(x=[values[i]], y=[counts[i]]) for i in range(len(values))]
454453
layout = go.Layout(
455454
title="Response Distribution",
456455
showlegend=False,
457456
xaxis={"type": "category"},
458457
)
459-
return go.Figure(data=[trace1, trace2], layout=layout)
458+
return go.Figure(data=traces, layout=layout)
460459

461460
# Show feature graph
462461
x = data_dict["x"]
@@ -481,7 +480,7 @@ def visualize(self, key=None):
481480
data_dict = {"data_type": "univariate", "names": values, "scores": counts}
482481
fig = plot_density(
483482
data_dict,
484-
color=COLORS[idx],
483+
color=COLORS[idx % len(COLORS)],
485484
name=str(current_class),
486485
is_categorical=is_categorical,
487486
)

python/interpret-core/interpret/visual/plot.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,19 @@
1313

1414
_log = logging.getLogger(__name__)
1515

16-
COLORS = ["#1f77b4", "#ff7f0e", "#808080"]
16+
COLORS = [
17+
"#1f77b4",
18+
"#ff7f0e",
19+
"#808080",
20+
"#2ca02c",
21+
"#d62728",
22+
"#9467bd",
23+
"#8c564b",
24+
"#e377c2",
25+
"#7f7f7f",
26+
"#bcbd22",
27+
"#17becf",
28+
]
1729

1830

1931
def is_multiclass_global_data_dict(data_dict):

0 commit comments

Comments
 (0)