Skip to content

Commit

Permalink
fix deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
oegedijk committed Dec 28, 2024
1 parent ef4d4c1 commit 634a85b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
7 changes: 6 additions & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Release Notes


## Version 0.4.8:

### Bug Fixes
- fix deprecated needs_proba parameter in make_scorer

## Version 0.4.7:


Expand All @@ -10,7 +15,7 @@
- Remove is_categorical_dtype as it is getting deprecated

### Improvements
- M
-
-


Expand Down
15 changes: 9 additions & 6 deletions explainerdashboard/explainer_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,22 @@
from joblib import Parallel, delayed


def append_dict_to_df(df, row_dict):
def append_dict_to_df(df: pd.DataFrame, row_dict: dict) -> pd.DataFrame:
"""Appends a row to the dataframe 'df' and returns the new
dataframe.
Args:
df (pd.DataFrame) data frame
row_dict (dict): row data
Returns:
pd.DataFrame
"""
return pd.concat([df, pd.DataFrame([row_dict])], ignore_index=True)
if not row_dict:
return df
# Create new DataFrame with same dtypes as input df
new_row_df = pd.DataFrame([row_dict], columns=df.columns).astype(df.dtypes)
return pd.concat([df, new_row_df], ignore_index=True)


class IndexNotFoundError(Exception):
Expand Down Expand Up @@ -625,11 +628,11 @@ def permutation_importances(

if isinstance(metric, str):
scorer = make_scorer(
metric, greater_is_better=greater_is_better, needs_proba=needs_proba
metric, greater_is_better=greater_is_better, response_method="predict_proba" if needs_proba else "predict"
)
elif not needs_proba or pos_label is None:
scorer = make_scorer(
metric, greater_is_better=greater_is_better, needs_proba=needs_proba
metric, greater_is_better=greater_is_better, response_method="predict"
)
else:
scorer = make_one_vs_all_scorer(metric, pos_label, greater_is_better)
Expand Down Expand Up @@ -1105,7 +1108,7 @@ def get_precision_df(
for i in range(n_classes):
new_row_dict["precision_" + str(i)] = np.mean(targets == i)

new_row_df = pd.DataFrame(new_row_dict, columns=precision_df.columns)
new_row_df = pd.DataFrame(new_row_dict, columns=precision_df.columns).astype(precision_df.dtypes)
precision_df = pd.concat([precision_df, new_row_df])
last_p_max = preds.max()

Expand Down
4 changes: 2 additions & 2 deletions explainerdashboard/explainers.py
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,7 @@ def ordered_cats(self, col, topx=None, sort="alphabet", pos_label=None):
index=self.get_col(col),
)
.abs()
.groupby(level=0)
.groupby(level=0, observed=False)
.mean()
.sort_values(ascending=False)
.index.tolist()
Expand All @@ -966,7 +966,7 @@ def ordered_cats(self, col, topx=None, sort="alphabet", pos_label=None):
index=self.get_col(col),
)
.abs()
.groupby(level=0)
.groupby(level=0, observed=False)
.mean()
.sort_values(ascending=False)
.nlargest(topx)
Expand Down

0 comments on commit 634a85b

Please sign in to comment.