Skip to content

Commit

Permalink
IL-374 Better rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
FelixFehseTNG committed Apr 4, 2024
1 parent 0d5e77a commit 94ea3ff
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 35 deletions.
35 changes: 33 additions & 2 deletions src/examples/user_journey.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -327,11 +327,42 @@
"list(failed_example_iterator.get_examples(eval_overview.id))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# from intelligence_layer.evaluation import evaluation_lineages_to_pandas\n",
"\n",
"\n",
"from intelligence_layer.evaluation import FailedExampleEvaluation\n",
"\n",
"\n",
"lineages = [\n",
" lineage\n",
" for lineage in evaluator.evaluation_lineages(eval_overview.id)\n",
" if not isinstance(lineage.evaluation.result, FailedExampleEvaluation) and not lineage.evaluation.result.correct\n",
"][:3]\n",
"\n",
"# df = evaluation_lineages_to_pandas(lineages)\n",
"# # df[\"output\"] = df[\"output\"].apply(\n",
"# # lambda o: sorted(o.scores.items(), key=lambda entry: entry[1])[-1]\n",
"# # )\n",
"# # df[\"result\"] = df[\"result\"].apply(lambda r: r.expected_label_missing)\n",
"# # df = df.rename(columns={\"result\": \"expected label missing\"})\n",
"# display(df)\n",
"\n",
"\n",
"for lineage in lineages:\n",
" display(lineage)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This confirms it: some expected labels are missing. Let's try fixing this.\n",
"This confirms it: The second example has an some expected labels are missing. Let's try fixing this.\n",
"\n",
"We can do this two ways: Adjust our set of labels or adjust the eval set. In this case, we'll do the latter.\n"
]
Expand Down Expand Up @@ -537,7 +568,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
"version": "3.11.8"
}
},
"nbformat": 4,
Expand Down
33 changes: 0 additions & 33 deletions src/intelligence_layer/use_cases/classify/classify.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,39 +168,6 @@ def do_evaluate_single_output(
)


class SingleLabelClassifyFailedExampleIterator:
def __init__(
self,
dataset_repository: DatasetRepository,
run_repository: RunRepository,
evaluation_repository: EvaluationRepository,
):
self.repository_navigator = RepositoryNavigator(
dataset_repository, run_repository, evaluation_repository
)

# TODO: Add test
def get_examples(
self, evaluation_overview_id: str, first_n: int = 0
) -> Iterable[Example[ClassifyInput, str]]:
evaluation_lineages = self.repository_navigator.evaluation_lineages(
evaluation_id=evaluation_overview_id,
input_type=ClassifyInput,
expected_output_type=str,
output_type=SingleLabelClassifyOutput,
evaluation_type=SingleLabelClassifyEvaluation,
)
count_yielded = 0
for lineage in evaluation_lineages:
if first_n != 0 and count_yielded >= first_n:
break
if (
isinstance(lineage.evaluation.result, FailedExampleEvaluation)
or not lineage.evaluation.result.correct
):
count_yielded += 1
yield lineage.example


class MultiLabelClassifyEvaluation(BaseModel):
"""The evaluation of a single multi-label classification example.
Expand Down

0 comments on commit 94ea3ff

Please sign in to comment.