Skip to content

Commit

Permalink
multiple (1)
Browse files Browse the repository at this point in the history
  • Loading branch information
mgraffg committed Feb 13, 2025
1 parent 77a3664 commit 63c3dd4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 11 additions & 2 deletions CompStats/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ def __sklearn_clone__(self):

def __repr__(self):
"""Prediction statistics with standard error in parenthesis"""
return f"<{self.__class__.__name__}>\n{self}"
arg = 'score_func' if self.error_func is not None else 'error_func'
func_name = self.statistic_func.__name__
return f"<{self.__class__.__name__}({arg}={func_name})>\n{self}"

def __str__(self):
"""Prediction statistics with standard error in parenthesis"""
Expand All @@ -152,7 +154,14 @@ def __str__(self):
output = ["Statistic with its standard error (se)"]
output.append("statistic (se)")
for key, value in self.statistic.items():
output.append(f'{value:0.4f} ({se[key]:0.4f}) <= {key}')
if isinstance(value, float):
desc = f'{value:0.4f} ({se[key]:0.4f}) <= {key}'
else:
desc = [f'{v:0.4f} ({k:0.4f})'
for v, k in zip(value, se[key])]
desc = ', '.join(desc)
desc = f'{desc} <= {key}'
output.append(desc)
return "\n".join(output)

def __call__(self, y_pred, name=None):
Expand Down
2 changes: 2 additions & 0 deletions CompStats/tests/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ def test_f1_score():
assert 'forest' in perf.statistic
_ = metrics.f1_score(y_val, hy, average='macro')
assert _ == perf.statistic['forest']
perf = f1_score(y_val, hy, average=None)
assert str(perf) is None


def test_accuracy_score():
Expand Down

0 comments on commit 63c3dd4

Please sign in to comment.