Skip to content

Commit

Permalink
[python] fix for pandas v1.2
Browse files Browse the repository at this point in the history
Even after the `-1 * x` fix, ALE plots looked like straight lines pandas-dev/pandas#38749
  • Loading branch information
hbaniecki committed Dec 28, 2020
1 parent a22a6da commit 5bd310c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def split_over_variables_and_labels(split_profile, type, groups, span):


def norm(x, loc, scale):
return np.exp(-((x - loc) / scale) ** 2 / 2) / np.pi / np.sqrt(2) / scale
return np.exp(-1 * ((x - loc) / scale) ** 2 / 2) / np.pi / np.sqrt(2) / scale


def prepare_numerical_categorical(all_profiles, variables, variable_type):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ def calculate_variable_profile(predict_function,

profiles = pd.concat(profile)
# convert the variable types
profiles.loc[:, list(variable_splits)] = profiles.loc[:, list(variable_splits)].convert_dtypes()
if pd.__version__ >= '1.2.0':
# convert_floating=False since pandas v1.2 seem to have issues
profiles.loc[:, list(variable_splits)] = profiles.loc[:, list(variable_splits)].convert_dtypes(convert_floating=False)
else:
profiles.loc[:, list(variable_splits)] = profiles.loc[:, list(variable_splits)].convert_dtypes()

return profiles

Expand Down

0 comments on commit 5bd310c

Please sign in to comment.