GsdEmulationPipeline#
- class mobgap.gait_sequences.pipeline.GsdEmulationPipeline(
- algo: BaseGsDetector,
- *,
- convert_to_body_frame: bool = True,
Run a GSD algorithm in isolation on a Gait Dataset.
This wraps any GSD algorithm and allows to apply it to a single datapoint of a Gait Dataset or optimize it based on a whole dataset.
This pipeline can be used in combination with the
tpcp.validateandtpcp.optimizemodules to evaluate or improve the performance of a GSD algorithm.- Parameters:
- algo
The GSD algorithm that should be run/evaluated.
- convert_to_body_frame
If True, the data will be converted to the body frame before running the algorithm. This is the default, as most algorithm expect the data in the body frame. If your data is explictly not aligned and your algorithm supports sensor frame/unaligned input you might want to set this to False.
- Attributes:
- gs_list_
A dataframe specifying the detected gait sequences. The dataframe has a
startandendcolumn, specifying the start and end index of the gait sequence. The values are specified as samples after the start of the recording (i.e. the start of thedata).- algo_
The GSD algo instance with all results after running the algorithm. This can be helpful for debugging or further analysis.
Methods
clone()Create a new instance of the class with all parameters copied over.
get_params([deep])Get parameters for this algorithm.
run(datapoint)Run the pipeline on a single data point.
safe_run(datapoint)Run the pipeline with some additional checks.
score(datapoint)Score the performance of the GSD algorithm of a single datapoint using standard metrics.
self_optimize(dataset, **kwargs)Run a "self-optimization" of a GSD-algorithm (if it implements the respective method).
self_optimize_with_info(dataset, **kwargs)Optimize the input parameters of the pipeline or algorithm using any logic.
set_params(**params)Set the parameters of this Algorithm.
- __init__(
- algo: BaseGsDetector,
- *,
- convert_to_body_frame: bool = True,
- clone() Self[source]#
Create a new instance of the class with all parameters copied over.
This will create a new instance of the class itself and all nested objects
- get_params(deep: bool = True) dict[str, Any][source]#
Get parameters for this algorithm.
- Parameters:
- deep
Only relevant if object contains nested algorithm objects. If this is the case and deep is True, the params of these nested objects are included in the output using a prefix like
nested_object_name__(Note the two “_” at the end)
- Returns:
- params
Parameter names mapped to their values.
- run(
- datapoint: BaseGaitDatasetWithReference,
Run the pipeline on a single data point.
This extracts the imu_data (
data_ss) and the sampling rate (sampling_rate_hz) from the datapoint and uses thedetectmethod of the GSD algorithm to detect the gait sequences.- Parameters:
- datapoint
A single datapoint of a Gait Dataset with reference information.
- Returns:
- self
The pipeline instance with the detected gait sequences stored in the
gs_list_attribute.
- safe_run(
- datapoint: DatasetT,
Run the pipeline with some additional checks.
It is preferred to use this method over
run, as it can catch some simple implementation errors of custom pipelines.The following things are checked:
The run method must return
self(or at least an instance of the pipeline)The run method must set result attributes on the pipeline
All result attributes must have a trailing
_in their nameThe run method must not modify the input parameters of the pipeline
- Parameters:
- datapoint
An instance of a
tpcp.Datasetcontaining only a single datapoint. The structure of the data will depend on the dataset.
- Returns:
- self
The class instance with all result attributes populated
- score(
- datapoint: BaseGaitDatasetWithReference,
Score the performance of the GSD algorithm of a single datapoint using standard metrics.
This method applies the GSD algorithm to the datapoint (using the implemented
runmethod) and calculates the performance metrics based on the detected gait sequences and the reference gait sequences.This method can be used as a scoring function in the
tpcp.validatemodule.- Parameters:
- datapoint
A single datapoint of a Gait Dataset with reference information.
- Returns:
- dict
Dictionary of performance metrics.
See also
calculate_matched_gsd_performance_metricsFor calculating performance metrics based on the matched overlap with the reference.
calculate_unmatched_gsd_performance_metricsFor calculating performance metrics without matching the detected and reference gait sequences.
categorize_intervals_per_sampleFor categorizing the detected and reference gait sequences on a sample-wise level.
- self_optimize(
- dataset: BaseGaitDatasetWithReference,
- **kwargs: Unpack[dict[str, Any]],
Run a “self-optimization” of a GSD-algorithm (if it implements the respective method).
This method extracts all data and reference gait sequences from the dataset and uses them to optimize the algorithm by calling the
self_optimizemethod of the GSD algorithm (if it is implemented).Note, that this is only useful for algorithms with “internal” optimization logic (i.e. ML-based algorithms). If you want to optimize the hyperparameters of the algorithm, you should use the
tpcp.optimizemodule.- Parameters:
- dataset
A Gait Dataset with reference information.
- kwargs
Additional parameters required for the optimization process. This will be passed to the
self_optimizemethod of the GSD algorithm.
- Returns:
- self
The pipeline instance with the optimized GSD algorithm.
- self_optimize_with_info(
- dataset: DatasetT,
- **kwargs,
Optimize the input parameters of the pipeline or algorithm using any logic.
This is equivalent to
self_optimize, but allows you to return additional information as a second return value. If you implement this method, there is no need to implementself_optimizeas well.- Parameters:
- dataset
An instance of a
tpcp.Datasetcontaining one or multiple data points that can be used for training. The structure of the data and the available reference information will depend on the dataset.- kwargs
Additional parameters required for the optimization process.
- Returns:
- self
The class instance with optimized input parameters.
- info
An arbitrary piece of information