Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

visualize has a bug for categorical features #119

Open
arrabi opened this issue Mar 31, 2020 · 0 comments
Open

visualize has a bug for categorical features #119

arrabi opened this issue Mar 31, 2020 · 0 comments
Labels
bug Something isn't working

Comments

@arrabi
Copy link

arrabi commented Mar 31, 2020

This is regarding this file:
https://github.com/interpretml/interpret/blame/master/python/interpret-core/interpret/data/response.py

MarginalExplanation.visualize(key) has a bug that prevents it from processing categorical features correctly. Changing the following lines will fix it:

move line #137:
bin_size = density_dict["names"][1] - density_dict["names"][0]

to be in the else (line #142)
if is_categorical:
trace1 = go.Histogram(x=data_dict["x"], name="x density", yaxis="y2")
else:
bin_size = density_dict["names"][1] - density_dict["names"][0]
trace1 = go.Histogram(
x=data_dict["x"],
name="x density",
yaxis="y2",
autobinx=False,
xbins=dict(
start=density_dict["names"][0],
end=density_dict["names"][-1],
size=bin_size,
),
)

and then move line 154:
resp_bin_size = density_dict["names"][1] - density_dict["names"][0]

create a new if statement, and put this line there: (line 157)
if is_categorical:
trace2 = go.Histogram(x=data_dict["y"], name="y density", xaxis="x2")
else:
resp_bin_size = density_dict["names"][1] - density_dict["names"][0]
trace2 = go.Histogram(
y=data_dict["y"],
name="y density",
xaxis="x2",
autobiny=False,
ybins=dict(
start=resp_density_dict["names"][0],
end=resp_density_dict["names"][-1],
size=resp_bin_size,
),
)

this would resolve the issue.

@paulbkoch paulbkoch added the bug Something isn't working label Jan 22, 2023
@paulbkoch paulbkoch mentioned this issue Jan 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

2 participants