Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collect additional metrics during collation #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion ablation/collate.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging
import os
from typing import Collection, Optional

import click
import pandas as pd
Expand All @@ -24,12 +25,13 @@ def read_collation() -> pd.DataFrame:
return pykeen_report.utils.read_ablation_collation(COLLATION_PATH)


def collate(key: str = 'hits@10') -> pd.DataFrame:
def collate(key: str = 'hits@10', additional_metrics: Optional[Collection[str]] = None) -> pd.DataFrame:
"""Collate all results for a given metric."""
return pykeen_report.utils.collate_ablation(
results_directory=RESULTS,
output_path=COLLATION_PATH,
key=key,
additional_metrics=additional_metrics,
)


Expand Down
8 changes: 7 additions & 1 deletion src/pykeen_report/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import os
from copy import deepcopy
from pathlib import Path
from typing import Any, Iterable, Mapping, Optional, Type, Union
from typing import Any, Collection, Iterable, Mapping, Optional, Type, Union

import pandas as pd
from tqdm import tqdm
Expand All @@ -33,11 +33,14 @@ def collate_ablation(
results_directory: str,
output_path: str,
key: str,
additional_metrics: Optional[Collection[str]] = None,
) -> pd.DataFrame:
"""Collate all results for a given metric.

:param key: The metric which you care about. Should be the same one against which you
optimized
:param additional_metrics:
Additional metrics to collect.
"""
columns = [
'searcher',
Expand All @@ -55,6 +58,9 @@ def collate_ablation(
'evaluation_time',
key,
]
if additional_metrics is None:
additional_metrics = []
columns += list(additional_metrics)

directories = [
(directory, filenames)
Expand Down