cpdbench.CPDBench

 1from cpdbench.control.TestbenchController import TestbenchController, TestrunType
 2from cpdbench.utils import Logger, BenchConfig
 3
 4
 5class CPDBench:
 6    """Main class for accessing the CPDBench functions"""
 7
 8    def __init__(self):
 9        self._datasets = []
10        self._algorithms = []
11        self._metrics = []
12        self._logger = None
13
14    def start(self, config_file: str = None) -> None:
15        """Start the execution of the CDPBench environment
16        :param config_file: Path to the CDPBench configuration file; defaults to 'config.yml'
17        """
18        BenchConfig.load_config(config_file)
19        self._logger = Logger.get_application_logger()
20        self._logger.debug('CPDBench object created')
21        self._logger.info("Starting CPDBench")
22        self._logger.info(f"Got {len(self._datasets)} datasets, {len(self._algorithms)} algorithms and "
23                          f"{len(self._metrics)} metrics")
24        bench = TestbenchController()
25        bench.execute_testrun(TestrunType.NORMAL_RUN, self._datasets, self._algorithms, self._metrics)
26
27    def validate(self, config_file: str = 'config.yml') -> None:
28        """Validate the given functions for a full bench run. Throws an exception if the validation fails.
29        :param config_file: Path to the CDPBench configuration file; defaults to 'config.yml'
30        """
31        BenchConfig.load_config(config_file)
32        self._logger = Logger.get_application_logger()
33        self._logger.debug('CPDBench object created')
34        self._logger.info("Starting CPDBench validator")
35        self._logger.info(f"Got {len(self._datasets)} datasets, {len(self._algorithms)} algorithms and "
36                          f"{len(self._metrics)} metrics")
37        bench = TestbenchController()
38        bench.execute_testrun(TestrunType.VALIDATION_RUN, self._datasets, self._algorithms, self._metrics)
39
40    def dataset(self, function):
41        """Decorator for dataset functions which create CPDDataset objects"""
42
43        # self._logger.debug(f'Got a dataset function: {Utils.get_name_of_function(function)}')
44        self._datasets.append(function)
45        return function
46
47    def algorithm(self, function):
48        """Decorator for algorithm functions which execute changepoint algorithms"""
49
50        # self._logger.debug(f'Got an algorithm function: {Utils.get_name_of_function(function)}')
51        self._algorithms.append(function)
52        return function
53
54    def metric(self, function):
55        """Decorator for metric functions which evaluate changepoint results"""
56
57        # self._logger.debug(f'Got a metric function: {Utils.get_name_of_function(function)}')
58        self._metrics.append(function)
59        return function
class CPDBench:
 6class CPDBench:
 7    """Main class for accessing the CPDBench functions"""
 8
 9    def __init__(self):
10        self._datasets = []
11        self._algorithms = []
12        self._metrics = []
13        self._logger = None
14
15    def start(self, config_file: str = None) -> None:
16        """Start the execution of the CDPBench environment
17        :param config_file: Path to the CDPBench configuration file; defaults to 'config.yml'
18        """
19        BenchConfig.load_config(config_file)
20        self._logger = Logger.get_application_logger()
21        self._logger.debug('CPDBench object created')
22        self._logger.info("Starting CPDBench")
23        self._logger.info(f"Got {len(self._datasets)} datasets, {len(self._algorithms)} algorithms and "
24                          f"{len(self._metrics)} metrics")
25        bench = TestbenchController()
26        bench.execute_testrun(TestrunType.NORMAL_RUN, self._datasets, self._algorithms, self._metrics)
27
28    def validate(self, config_file: str = 'config.yml') -> None:
29        """Validate the given functions for a full bench run. Throws an exception if the validation fails.
30        :param config_file: Path to the CDPBench configuration file; defaults to 'config.yml'
31        """
32        BenchConfig.load_config(config_file)
33        self._logger = Logger.get_application_logger()
34        self._logger.debug('CPDBench object created')
35        self._logger.info("Starting CPDBench validator")
36        self._logger.info(f"Got {len(self._datasets)} datasets, {len(self._algorithms)} algorithms and "
37                          f"{len(self._metrics)} metrics")
38        bench = TestbenchController()
39        bench.execute_testrun(TestrunType.VALIDATION_RUN, self._datasets, self._algorithms, self._metrics)
40
41    def dataset(self, function):
42        """Decorator for dataset functions which create CPDDataset objects"""
43
44        # self._logger.debug(f'Got a dataset function: {Utils.get_name_of_function(function)}')
45        self._datasets.append(function)
46        return function
47
48    def algorithm(self, function):
49        """Decorator for algorithm functions which execute changepoint algorithms"""
50
51        # self._logger.debug(f'Got an algorithm function: {Utils.get_name_of_function(function)}')
52        self._algorithms.append(function)
53        return function
54
55    def metric(self, function):
56        """Decorator for metric functions which evaluate changepoint results"""
57
58        # self._logger.debug(f'Got a metric function: {Utils.get_name_of_function(function)}')
59        self._metrics.append(function)
60        return function

Main class for accessing the CPDBench functions

def start(self, config_file: str = None) -> None:
15    def start(self, config_file: str = None) -> None:
16        """Start the execution of the CDPBench environment
17        :param config_file: Path to the CDPBench configuration file; defaults to 'config.yml'
18        """
19        BenchConfig.load_config(config_file)
20        self._logger = Logger.get_application_logger()
21        self._logger.debug('CPDBench object created')
22        self._logger.info("Starting CPDBench")
23        self._logger.info(f"Got {len(self._datasets)} datasets, {len(self._algorithms)} algorithms and "
24                          f"{len(self._metrics)} metrics")
25        bench = TestbenchController()
26        bench.execute_testrun(TestrunType.NORMAL_RUN, self._datasets, self._algorithms, self._metrics)

Start the execution of the CDPBench environment

Parameters
  • config_file: Path to the CDPBench configuration file; defaults to 'config.yml'
def validate(self, config_file: str = 'config.yml') -> None:
28    def validate(self, config_file: str = 'config.yml') -> None:
29        """Validate the given functions for a full bench run. Throws an exception if the validation fails.
30        :param config_file: Path to the CDPBench configuration file; defaults to 'config.yml'
31        """
32        BenchConfig.load_config(config_file)
33        self._logger = Logger.get_application_logger()
34        self._logger.debug('CPDBench object created')
35        self._logger.info("Starting CPDBench validator")
36        self._logger.info(f"Got {len(self._datasets)} datasets, {len(self._algorithms)} algorithms and "
37                          f"{len(self._metrics)} metrics")
38        bench = TestbenchController()
39        bench.execute_testrun(TestrunType.VALIDATION_RUN, self._datasets, self._algorithms, self._metrics)

Validate the given functions for a full bench run. Throws an exception if the validation fails.

Parameters
  • config_file: Path to the CDPBench configuration file; defaults to 'config.yml'
def dataset(self, function):
41    def dataset(self, function):
42        """Decorator for dataset functions which create CPDDataset objects"""
43
44        # self._logger.debug(f'Got a dataset function: {Utils.get_name_of_function(function)}')
45        self._datasets.append(function)
46        return function

Decorator for dataset functions which create CPDDataset objects

def algorithm(self, function):
48    def algorithm(self, function):
49        """Decorator for algorithm functions which execute changepoint algorithms"""
50
51        # self._logger.debug(f'Got an algorithm function: {Utils.get_name_of_function(function)}')
52        self._algorithms.append(function)
53        return function

Decorator for algorithm functions which execute changepoint algorithms

def metric(self, function):
55    def metric(self, function):
56        """Decorator for metric functions which evaluate changepoint results"""
57
58        # self._logger.debug(f'Got a metric function: {Utils.get_name_of_function(function)}')
59        self._metrics.append(function)
60        return function

Decorator for metric functions which evaluate changepoint results