Skip to content

Commit 5273678

Browse files
committed
fix pandas warnings
1 parent 924b976 commit 5273678

6 files changed

Lines changed: 10 additions & 10 deletions

File tree

python/dalex/NEWS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## Changelog
22

3-
### v1.8.0 (2026-01-19)
3+
### v1.8.0 (2026-01-20)
44

55
* substitute the deprecated `pkg_resources` dependency that breaks `dalex` ([#579](https://github.com/ModelOriented/DALEX/issues/579))
66
* remove the `ppscore` optional dependency used by the `aspect` module from `dalex[full]` as it imposes `pandas<2.0.0`

python/dalex/dalex/model_explanations/_aggregated_profiles/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def aggregate_profiles(all_profiles, mean_prediction, type, groups, center, span
1515
aggregated_profiles = \
1616
all_profiles. \
1717
loc[:, ["_vname_", "_label_", "_x_", "_yhat_", "_ids_", "_original_"] + groups]. \
18-
groupby(['_vname_', '_label_']). \
18+
groupby(['_vname_', '_label_'])[["_x_", "_yhat_", "_ids_", "_original_"] + groups]. \
1919
progress_apply(lambda split_profile: split_over_variables_and_labels(split_profile.copy(deep=True),
2020
type, groups, span)). \
2121
reset_index(level=[0, 1]) # remove level_2
@@ -83,7 +83,7 @@ def split_over_variables_and_labels(split_profile, type, groups, span):
8383

8484
par_profile = split_profile.groupby(['_x_'] + groups, sort=False). \
8585
apply(lambda point: (point['_yhat_'] * point['_w_']).sum() / point['_w_'].sum() \
86-
if point['_w_'].sum() != 0 else 0)
86+
if point['_w_'].sum() != 0 else 0, include_groups=False)
8787

8888
par_profile.name = '_yhat_'
8989
par_profile = par_profile.reset_index()

python/dalex/dalex/predict_explanations/_break_down/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def calculate_2d_changes(explainer,
121121

122122
yhats = explainer.predict(current_data)
123123
average_yhats[i] = yhats.mean()
124-
average_yhats_norm[i] = average_yhats[i] - diffs_1d[inds.iloc[i, 0]] - diffs_1d.iloc[inds.iloc[i, 1]]
124+
average_yhats_norm[i] = average_yhats[i] - diffs_1d.iloc[inds.iloc[i, 0]] - diffs_1d.iloc[inds.iloc[i, 1]]
125125

126126
columns = explainer.data.columns
127127
average_yhats = pd.Series(average_yhats)

python/dalex/dalex/predict_explanations/_ceteris_paribus/utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ def single_variable_profile(predict,
9797
ids = np.repeat(data.index.values, split_points.shape[0])
9898
new_data = data.loc[ids, :]
9999
original = new_data.loc[:, variable].copy()
100+
if pd.api.types.is_numeric_dtype(new_data[variable]):
101+
new_data[variable] = new_data[variable].astype('float')
100102
new_data.loc[:, variable] = np.tile(split_points, data.shape[0])
101103

102104
yhat = predict(model, new_data)

python/dalex/test/test_aggregated_profiles.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ def test_accumulated(self):
7474
self.assertIsInstance(fig1, Figure)
7575
self.assertIsInstance(fig2, Figure)
7676

77-
test1 = case1.result.groupby('_vname_').apply(lambda x: x['_yhat_'].abs().min()).tolist()
78-
test2 = case2.result.groupby('_vname_').apply(lambda x: x['_yhat_'].abs().min()).tolist()
77+
test1 = case1.result.groupby('_vname_')['_yhat_'].apply(lambda x: x.abs().min()).tolist()
78+
test2 = case2.result.groupby('_vname_')['_yhat_'].apply(lambda x: x.abs().min()).tolist()
7979

8080
self.assertListEqual(test1, np.zeros(len(test1)).tolist())
8181
self.assertListEqual(test2, np.zeros(len(test2)).tolist())

python/dalex/test/test_aspect.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
import unittest
2-
try:
3-
import ppscore
4-
except ImportError:
5-
raise unittest.SkipTest("`ppscore` not installed")
62

73
import numpy as np
84
import pandas as pd
@@ -23,6 +19,7 @@
2319
from dalex.aspect._predict_triplot.object import PredictTriplot
2420
from dalex.aspect._model_aspect_importance.object import ModelAspectImportance
2521

22+
@unittest.skip("Skipping test to avoid problems with `ppscore` versioning and dependencies.")
2623
class AspectTestTitanic(unittest.TestCase):
2724
def setUp(self):
2825
data = dx.datasets.load_titanic()
@@ -449,6 +446,7 @@ def test_model_triplot_class(self):
449446
self.assertIsInstance(fig8, HBox)
450447

451448

449+
@unittest.skip("Skipping test to avoid problems with `ppscore` versioning and dependencies.")
452450
class AspectTestFifa(unittest.TestCase):
453451
def setUp(self):
454452
data = dx.datasets.load_fifa()

0 commit comments

Comments
 (0)