src.fairreckitlib.evaluation.pipeline.evaluation_config

This module contains the metric configuration.

Classes:

MetricConfig: metric configuration.

This program has been developed by students from the bachelor Computer Science at Utrecht University within the Software Project course. © Copyright Utrecht University (Department of Information and Computing Sciences)

 1"""This module contains the metric configuration.
 2
 3Classes:
 4
 5    MetricConfig: metric configuration.
 6
 7This program has been developed by students from the bachelor Computer Science at
 8Utrecht University within the Software Project course.
 9© Copyright Utrecht University (Department of Information and Computing Sciences)
10"""
11
12from dataclasses import dataclass
13from typing import Any, Dict, Optional
14
15from ...core.config.config_object import ObjectConfig
16from ...data.filter.filter_config import DataSubsetConfig
17from ..metrics.metric_constants import KEY_METRIC_SUBGROUP
18
19
20@dataclass
21class MetricConfig(ObjectConfig):
22    """Metric Configuration.
23
24    name: the name of the metric.
25    params: the parameters of the metric.
26    subgroup: the subgroup of the metric.
27    """
28
29    subgroup: Optional[DataSubsetConfig]
30
31    def to_yml_format(self) -> Dict[str, Any]:
32        """Format metric configuration to a yml compatible dictionary.
33
34        Returns:
35            a dictionary containing the metric configuration.
36        """
37        yml_format = ObjectConfig.to_yml_format(self)
38        # only include subgroup if it is specified
39        if self.subgroup is not None:
40            yml_format[KEY_METRIC_SUBGROUP] = self.subgroup.to_yml_format()
41
42        return yml_format
@dataclass
class MetricConfig(src.fairreckitlib.core.config.config_object.ObjectConfig):
21@dataclass
22class MetricConfig(ObjectConfig):
23    """Metric Configuration.
24
25    name: the name of the metric.
26    params: the parameters of the metric.
27    subgroup: the subgroup of the metric.
28    """
29
30    subgroup: Optional[DataSubsetConfig]
31
32    def to_yml_format(self) -> Dict[str, Any]:
33        """Format metric configuration to a yml compatible dictionary.
34
35        Returns:
36            a dictionary containing the metric configuration.
37        """
38        yml_format = ObjectConfig.to_yml_format(self)
39        # only include subgroup if it is specified
40        if self.subgroup is not None:
41            yml_format[KEY_METRIC_SUBGROUP] = self.subgroup.to_yml_format()
42
43        return yml_format

Metric Configuration.

name: the name of the metric. params: the parameters of the metric. subgroup: the subgroup of the metric.

MetricConfig( name: str, params: Dict[str, Any], subgroup: Optional[src.fairreckitlib.data.filter.filter_config.DataSubsetConfig])
def to_yml_format(self) -> Dict[str, Any]:
32    def to_yml_format(self) -> Dict[str, Any]:
33        """Format metric configuration to a yml compatible dictionary.
34
35        Returns:
36            a dictionary containing the metric configuration.
37        """
38        yml_format = ObjectConfig.to_yml_format(self)
39        # only include subgroup if it is specified
40        if self.subgroup is not None:
41            yml_format[KEY_METRIC_SUBGROUP] = self.subgroup.to_yml_format()
42
43        return yml_format

Format metric configuration to a yml compatible dictionary.

Returns: a dictionary containing the metric configuration.