BaseChallenge#
- class gaitmap_challenges.challenge_base.BaseChallenge[source]#
Base class for all challenges.
Note, that we decided to use datas-classes for challenges to reduce the amount of code that needs to be written. This means, that you need to wrap your challenge into a dataclass decorator as well.
Besides providing an expected interface, this class provides a
_measure_timecontext manager that can be used within your implementation of therunmethod to measure the execution time of an algorithm. This will automatically set a number of results attributes about the start/end and runtime of the execution.- Other Parameters:
- VERSION
(Class Constant) The version of the challenge. In case of breaking changes, this should be increased.
- optimizer
The optimizer passed to the
runmethod.
- Attributes:
- run_start_datetime_utc_timestamp_
The start time of the execution of the challenge in UTC timestamp format.
- run_start_datetime_
The start time of the execution of the challenge in ISO format.
- end_start_datetime_utc_timestamp_
The end time of the execution of the challenge in UTC timestamp format.
- end_start_datetime_
The end time of the execution of the challenge in ISO format.
- runtime_
The runtime of the execution of the challenge in seconds.
- dataset_
The instance of the dataset class actually used in the challenge. This is usually a copy of the dataset class instance supplied to the challenge and has potentially some parameters overwritten to ensure that the challenge is executed as expected.
Methods
clone()Create a new instance of the class with all parameters copied over.
Get the main results of the challenge.
get_params([deep])Get parameters for this algorithm.
load_core_results(folder_path)Load the core results from a folder that have been stored using
save_core_results.run(optimizer)Run the challenge.
save_core_results(folder_path)Save the main results of the challenge to a folder.
set_params(**params)Set the parameters of this Algorithm.
- property _measure_time: Callable[[], Generator[None, None, None]]#
Context manager to measure the execution time of an algorithm.
Use this within your implementation of the
runmethod to measure the execution time of an algorithm.
- classmethod load_core_results(folder_path: Path) Dict[str, Any][source]#
Load the core results from a folder that have been stored using
save_core_results.The assumption is, that the output is identical to calling
get_core_resultson the challenge instance directly.When implementing this method, make sure that it remains compatible with results saved using older versions of the challenge_class.
- run(optimizer: BaseOptimize)[source]#
Run the challenge.