Commit ae0afb7a authored by mibaumgartner's avatar mibaumgartner
Browse files

improve case eval docu

parent 73599137
......@@ -210,8 +210,8 @@ task: Task000D3_Example
name: "Example" # [Optional]
dim: 3 # number of spatial dimensions of the data
# TODO: check these
target_class: # define class of interest for patient level evaluations # TODO: check if this should be included
# Note: need to use integer value which is defined below of target class!
target_class: 1 # [Optional] define class of interest for patient level evaluations
test_labels: True # manually splitted test set
labels: # classes of data set; need to start at 0
......
......@@ -15,7 +15,7 @@ limitations under the License.
"""
from collections import defaultdict
from typing import Dict, Sequence, Callable, Tuple, Union, Mapping
from typing import Dict, Sequence, Callable, Tuple, Union, Mapping, Optional
import numpy as np
from loguru import logger
......@@ -35,7 +35,7 @@ class _CaseEvaluator(AbstractEvaluator):
class_metrics_scalar: Mapping[str, Callable] = None,
score_metrics_curve: Mapping[str, Callable] = None,
class_metrics_curve: Mapping[str, Callable] = None,
target_class: int = None,
target_class: Optional[int] = None,
):
"""
Compute case level evaluation metrics
......@@ -73,7 +73,10 @@ class _CaseEvaluator(AbstractEvaluator):
self.score_metrics_curve = score_metrics_curve if score_metrics_curve is not None else {}
self.class_metrics_curve = class_metrics_curve if class_metrics_curve is not None else {}
self.target_class = target_class
if isinstance(target_class, str):
raise ValueError(f"Need integer value of target class not the name!")
self.target_class = int(target_class)
self.classes = classes
self.num_classes = len(classes)
......
......@@ -115,6 +115,13 @@ def check_dataset_file(task_name: str):
if ic != idx:
raise ValueError("Found wrong order of modalities in dataset info."
f"Found {found_mods} but expected {list(range(len(found_mods)))}")
# check target class
target_class = cfg.get("target_class", None)
if target_class is not None and not isinstance(target_class, int):
raise ValueError("If target class is defined, it needs to be an integer, "
f"found {type(target_class)} : {target_class}")
print("Dataset info check complete.")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment