Skip to content

Commit

Permalink
WIP - Prepare class for label counts
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianNiehusTNG committed Apr 3, 2024
1 parent bc04b36 commit 31e8301
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/intelligence_layer/use_cases/classify/classify.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,27 +63,39 @@ class SingleLabelClassifyEvaluation(BaseModel):
correct: bool


class SingleLabelClassifyLabelCounts(BaseModel):
## TODO: DocString
count_correctly_assigned: int = 0
count_incorrectly_assigned: int = 0


class AggregatedSingleLabelClassifyEvaluation(BaseModel):
"""The aggregated evaluation of a single label classify implementation against a dataset.
Attributes:
percentage_correct: Percentage of answers that were considered to be correct
assignments_per_label: Mapping stating how often the respective label was assigned correctly or incorrectly
"""

percentage_correct: float
assignments_per_label: Mapping[str, SingleLabelClassifyLabelCounts]


class SingleLabelClassifyAggregationLogic(
AggregationLogic[
SingleLabelClassifyEvaluation, AggregatedSingleLabelClassifyEvaluation
]
):
def aggregate(
def aggregate( # TODO: Need the specific labels here
self, evaluations: Iterable[SingleLabelClassifyEvaluation]
) -> AggregatedSingleLabelClassifyEvaluation:
acc = MeanAccumulator()
label_counts = Mapping[str, SingleLabelClassifyLabelCounts]
for evaluation in evaluations:
acc.add(1.0 if evaluation.correct else 0.0)
## TODO: Add info to label counts


return AggregatedSingleLabelClassifyEvaluation(percentage_correct=acc.extract())


Expand Down

0 comments on commit 31e8301

Please sign in to comment.