Skip to content

Commit

Permalink
chore: sort evaluation results (#45)
Browse files Browse the repository at this point in the history
Now we can get a consistent natural ordering of the output when
performing evaluation. Previously we converted sets directly into lists
which caused a different ordering on each run.
  • Loading branch information
eloy-encord authored Mar 13, 2024
1 parent 19fe3fe commit 6e514bc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
5 changes: 3 additions & 2 deletions clip_eval/evaluation/evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing import Literal

import numpy as np
from natsort import natsorted
from tabulate import tabulate

from clip_eval.common.data_models import EmbeddingDefinition, Embeddings
Expand All @@ -21,8 +22,8 @@ def print_evaluation_results(
classifier_column: (Literal["linear_probe"] | Literal["zero_shot"] | Literal["wKNN"]) = "linear_probe",
):
defs = list(results.keys())
model_names = list(set(map(lambda d: d.model, defs)))
dataset_names = list(set(map(lambda d: d.dataset, defs)))
model_names = natsorted(set(map(lambda d: d.model, defs)))
dataset_names = natsorted(set(map(lambda d: d.dataset, defs)))

table: list[list[float | str]] = [
["Model/Dataset"] + dataset_names,
Expand Down
30 changes: 17 additions & 13 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ tabulate = "^0.9.0"
sentencepiece = "^0.2.0"
protobuf = "^4.25.3"
open-clip-torch = "^2.24.0"
natsort = "^8.4.0"

[tool.poetry.group.dev.dependencies]
mypy = "^1.8.0"
Expand Down

0 comments on commit 6e514bc

Please sign in to comment.