Skip to content

Commit c8fd7bd

Browse files
fix bugs
1 parent 674ead7 commit c8fd7bd

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ where = ["."]
9393

9494

9595
[tool.setuptools.package-data]
96-
"*" = ["*.csv", "*json", "*.yml", "*.css", "*.js", "*.png"]
96+
"*" = ["*.csv", "*json", "*.yml", "*.css", "*.js", "*.png", "*.ico"]
9797

9898
[tool.pytest.ini_options]
9999
pythonpath = ["."]

shapash/plots/plot_bar_chart.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,16 @@ def plot_bar_chart(
103103
bars = []
104104
for num, expl in enumerate(zip(var_dict, x_val, contrib)):
105105
feat_name, x_val_el, contrib_value = expl
106-
group_name = inv_features_dict.get(feat_name)
106+
is_grouped = False
107107
if x_val_el == "":
108108
ylabel = f"<i>{feat_name}</i>"
109109
hoverlabel = f"<b>{feat_name}</b>"
110110
else:
111111
# If bar is a group of features, hovertext includes the values of the features of the group
112112
# And color changes
113+
group_name = inv_features_dict.get(feat_name)
113114
if features_groups is not None and group_name in features_groups.keys() and len(index_value) > 0:
115+
is_grouped = True
114116
feat_groups_values = x_init[features_groups[group_name]].loc[index_value[0]]
115117
hoverlabel = "<br />".join(
116118
[
@@ -146,7 +148,7 @@ def plot_bar_chart(
146148
color = -1 if x_val_el != "" else -2
147149

148150
# If the bar is a group of features we modify the color
149-
if group_name is not None:
151+
if is_grouped:
150152
bar_color = style_dict["featureimp_groups"][0] if color == 1 else style_dict["featureimp_groups"][1]
151153
else:
152154
bar_color = dict_local_plot_colors[color]["color"]

shapash/plots/plot_scatter_prediction.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ def _prediction_classification_plot(
220220
df_pred = pd.concat(
221221
[y_proba_values.reset_index(), y_pred.reset_index(drop=True), target.reset_index(drop=True)], axis=1
222222
)
223-
print(df_pred)
224223
df_pred.set_index(df_pred.columns[0], inplace=True)
225224
df_pred.columns = ["proba_values", "predict_class", "target"]
226225
df_pred["wrong_predict"] = 1

shapash/webapp/utils/callbacks.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -833,8 +833,12 @@ def determine_total_pages_and_display(
833833
Tuple[int, str, int]: Total pages, display properties, and updated page number.
834834
"""
835835
display_groups = explainer.features_groups is not None and bool_group
836-
nb_features = len(explainer.features_imp_groups) if display_groups else len(explainer.features_imp)
837-
total_pages = nb_features // features + 1
836+
if explainer._case == "classification":
837+
nb_features = len(explainer.features_imp_groups[0]) if display_groups else len(explainer.features_imp[0])
838+
elif explainer._case == "regression":
839+
nb_features = len(explainer.features_imp_groups) if display_groups else len(explainer.features_imp)
840+
841+
total_pages = (nb_features - 1) // features + 1
838842
if (total_pages == 1) or (group_name):
839843
display_page = {"display": "none"}
840844
else:

0 commit comments

Comments
 (0)