From 4652fd5d16f0c253e9391a0a7fb929dd61ee081b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20Kir=C3=A1ly?= Date: Sun, 10 Sep 2023 14:20:21 +0200 Subject: [PATCH] fix groupbys --- skpro/distributions/mixture.py | 2 +- skpro/metrics/base.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/skpro/distributions/mixture.py b/skpro/distributions/mixture.py index d94e8c929..31dba9e52 100644 --- a/skpro/distributions/mixture.py +++ b/skpro/distributions/mixture.py @@ -134,7 +134,7 @@ def _average_df(self, df_list, weights=None): n_df = len(df_list) df_weighted = [df * w for df, w in zip(df_list, weights)] df_concat = pd.concat(df_weighted, axis=1, keys=range(n_df)) - df_res = df_concat.T.groupby(level=-1).sum() + df_res = df_concat.T.groupby(level=-1).T.sum() return df_res def pdf(self, x): diff --git a/skpro/metrics/base.py b/skpro/metrics/base.py index 4fea4f20e..a9de34f9e 100644 --- a/skpro/metrics/base.py +++ b/skpro/metrics/base.py @@ -116,9 +116,9 @@ def evaluate(self, y_true, y_pred, **kwargs): if self.score_average and multioutput == "uniform_average": out = out.mean(axis=1).iloc[0] # average over all if self.score_average and multioutput == "raw_values": - out = out.T.groupby(level=0).mean() # average over scores + out = out.T.groupby(level=0).T.mean() # average over scores if not self.score_average and multioutput == "uniform_average": - out = out.T.groupby(level=1).mean() # average over variables + out = out.T.groupby(level=1).T.mean() # average over variables if not self.score_average and multioutput == "raw_values": out = out # don't average @@ -202,9 +202,9 @@ def evaluate_by_index(self, y_true, y_pred, **kwargs): if self.score_average and multioutput == "uniform_average": out = out.mean(axis=1) # average over all if self.score_average and multioutput == "raw_values": - out = out.T.groupby(level=0).mean() # average over scores + out = out.T.groupby(level=0).T.mean() # average over scores if not self.score_average and multioutput == "uniform_average": - out = out.T.groupby(level=1).mean() # average over variables + out = out.T.groupby(level=1).T.mean() # average over variables if not self.score_average and multioutput == "raw_values": out = out # don't average