cpdbench.control.CPDValidationResult

 1import datetime
 2import traceback
 3
 4from cpdbench.control.CPDResult import CPDResult
 5
 6
 7class CPDValidationResult(CPDResult):
 8    """Container for a validation run result."""
 9
10    def __init__(self, errors: list, datasets: list[str], algorithms: list[str], metrics: list[str]):
11        """Construct a validation result object
12        :param errors: list of occurred errors during validation
13        :param datasets: list of all dataset names as strings
14        :param algorithms: list of all used changepoint algorithms as strings
15        :param metrics: list of all metrics as strings
16        """
17        self._errors = []
18        for error in errors:
19            self._errors.append(''.join(traceback.format_exception(None, error, error.__traceback__)))
20        self._created = datetime.datetime.now()
21        self._last_updated = self._created
22        self._datasets = datasets
23        self._algorithms = algorithms
24        self._metrics = metrics
25
26    def get_result_as_dict(self) -> dict:
27        """Return the complete result with all dataset results and metadata as python dict
28        :return: the result as python dict
29        """
30        return {
31            "datasets": self._datasets,
32            "algorithms": self._algorithms,
33            "metrics": self._metrics,
34            "created": self._created.strftime("%m/%d/%Y, %H:%M:%S"),
35            "last_updated": self._last_updated.strftime("%m/%d/%Y, %H:%M:%S"),
36            "errors": self._errors
37        }
class CPDValidationResult(cpdbench.control.CPDResult.CPDResult):
 8class CPDValidationResult(CPDResult):
 9    """Container for a validation run result."""
10
11    def __init__(self, errors: list, datasets: list[str], algorithms: list[str], metrics: list[str]):
12        """Construct a validation result object
13        :param errors: list of occurred errors during validation
14        :param datasets: list of all dataset names as strings
15        :param algorithms: list of all used changepoint algorithms as strings
16        :param metrics: list of all metrics as strings
17        """
18        self._errors = []
19        for error in errors:
20            self._errors.append(''.join(traceback.format_exception(None, error, error.__traceback__)))
21        self._created = datetime.datetime.now()
22        self._last_updated = self._created
23        self._datasets = datasets
24        self._algorithms = algorithms
25        self._metrics = metrics
26
27    def get_result_as_dict(self) -> dict:
28        """Return the complete result with all dataset results and metadata as python dict
29        :return: the result as python dict
30        """
31        return {
32            "datasets": self._datasets,
33            "algorithms": self._algorithms,
34            "metrics": self._metrics,
35            "created": self._created.strftime("%m/%d/%Y, %H:%M:%S"),
36            "last_updated": self._last_updated.strftime("%m/%d/%Y, %H:%M:%S"),
37            "errors": self._errors
38        }

Container for a validation run result.

CPDValidationResult(errors: list, datasets: list, algorithms: list, metrics: list)
11    def __init__(self, errors: list, datasets: list[str], algorithms: list[str], metrics: list[str]):
12        """Construct a validation result object
13        :param errors: list of occurred errors during validation
14        :param datasets: list of all dataset names as strings
15        :param algorithms: list of all used changepoint algorithms as strings
16        :param metrics: list of all metrics as strings
17        """
18        self._errors = []
19        for error in errors:
20            self._errors.append(''.join(traceback.format_exception(None, error, error.__traceback__)))
21        self._created = datetime.datetime.now()
22        self._last_updated = self._created
23        self._datasets = datasets
24        self._algorithms = algorithms
25        self._metrics = metrics

Construct a validation result object

Parameters
  • errors: list of occurred errors during validation
  • datasets: list of all dataset names as strings
  • algorithms: list of all used changepoint algorithms as strings
  • metrics: list of all metrics as strings
def get_result_as_dict(self) -> dict:
27    def get_result_as_dict(self) -> dict:
28        """Return the complete result with all dataset results and metadata as python dict
29        :return: the result as python dict
30        """
31        return {
32            "datasets": self._datasets,
33            "algorithms": self._algorithms,
34            "metrics": self._metrics,
35            "created": self._created.strftime("%m/%d/%Y, %H:%M:%S"),
36            "last_updated": self._last_updated.strftime("%m/%d/%Y, %H:%M:%S"),
37            "errors": self._errors
38        }

Return the complete result with all dataset results and metadata as python dict

Returns

the result as python dict