Skip to content

Commit

Permalink
Simpler
Browse files Browse the repository at this point in the history
Once we remove all deprecated code, score will be very short since most of the work is done in mean_skill
  • Loading branch information
ecomodeller committed Dec 14, 2023
1 parent 96050c3 commit dd85573
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions modelskill/comparison/_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,9 @@ def weighted_mean(x):
agg[metric.__name__] = weighted_mean # type: ignore
res = skilldf.groupby(by).agg(agg)

# TODO is this correct?
res.index.name = "model"

# output
res = cmp._add_as_col_if_not_in_index(df, res, fields=["model", "variable"])
return SkillTable(res.astype({"n": int}))
Expand Down Expand Up @@ -1031,14 +1034,7 @@ def score(

metric_name = metric if isinstance(metric, str) else metric.__name__

# TODO dict comprehension?
score = {}
for model in models:
mtr_val = df.loc[model][metric_name]
if not np.isscalar(mtr_val):
# e.g. mean over different variables!
mtr_val = mtr_val.values.mean()
score[model] = mtr_val
score = df[metric_name].to_dict()

return score

Expand Down

0 comments on commit dd85573

Please sign in to comment.