Skip to content

Commit

Permalink
CU-8695vu71q: Make report identical run to run in identical cases (Co…
Browse files Browse the repository at this point in the history
  • Loading branch information
mart-r authored Sep 30, 2024
1 parent a9544f7 commit b433195
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions medcat/utils/regression/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,13 @@ def iter_examples(self, strictness_threshold: Strictness
Yields:
Iterable[Tuple[FinalTarget, Tuple[Finding, Optional[str]]]]: The placeholder, phrase, finding, CUI, and name.
"""
for srd in self.per_phrase_results.values():
for target, finding in srd.examples:
phrases = sorted(self.per_phrase_results.keys())
for phrase in phrases:
srd = self.per_phrase_results[phrase]
# sort by finding 1st, found CUI 2nd, and used name 3rd
sorted_examples = sorted(
srd.examples, key=lambda tf: (tf[1][0].name, str(tf[1][1]), tf[0].name))
for target, finding in sorted_examples:
if finding[0] not in STRICTNESS_MATRIX[strictness_threshold]:
yield target, finding

Expand Down Expand Up @@ -490,7 +495,8 @@ def dict(self, **kwargs) -> dict:
# NOTE: need to propagate here manually so the strictness keyword
# makes sense and doesn't cause issues due being to unexpected keyword
per_phrase_results = {
phrase: res.dict(**kwargs) for phrase, res in self.per_phrase_results.items()
phrase: res.dict(**kwargs) for phrase, res in
sorted(self.per_phrase_results.items(), key=lambda it: it[0])
}
d['per_phrase_results'] = per_phrase_results
return d
Expand Down Expand Up @@ -654,8 +660,8 @@ def get_report(self, phrases_separately: bool,
if hide_empty:
empty_text = f' A total of {nr_of_empty} cases did not match any CUIs and/or names.'
ret_vals = [f"""A total of {len(self.parts)} parts were kept track of within the group "{self.name}".
And a total of {total_total} (sub)cases were checked.{empty_text}"""]
allowed_fingings_str = [f.name for f in allowed_findings]
And a total of {total_total} (sub)cases were checked.{empty_text}"""]
allowed_fingings_str = sorted([f.name for f in allowed_findings])
ret_vals.extend([
f"At the strictness level of {strictness} (allowing {allowed_fingings_str}):",
f"The number of total successful (sub) cases: {total_s} "
Expand Down

0 comments on commit b433195

Please sign in to comment.