leads.data_persistence.analyzer.inference#
Module Contents#
Classes#
Infer the speed based on the front wheel speed or the rear wheel speed. |
|
Infer the speed based on the acceleration. |
|
Infer the speed based on the mileage. |
|
Infer the speed based on the GPS ground speed. |
|
Infer the speed based on the GPS position. This is equivalent to inferring the mileage based on GPS position and then inferring the speed based on the mileage. |
|
Infer the forward acceleration based on the speed. Note that this is not always reliable because speed is a scalar, but forward acceleration is not. Accelerating in reverse will still be counted as forward acceleration. |
|
Infer the mileage based on the speed. |
|
Infer the mileage based on the speed. |
|
Offset the delay introduced by camera recording and video encoding so that the sensor data and the picture of the same frame match. |
|
API#
- class leads.data_persistence.analyzer.inference.Inference(required_depth: tuple[int, int] = (0, 0), required_header: tuple[str, ...] = DEFAULT_HEADER)[source]#
Bases:
objectInitialization
Declare the scale of data this inference requires. :param required_depth: (-depth backward, depth forward) :param required_header: the necessary header that the dataset must contain for this inference to work
- abstractmethod complete(*rows: dict[str, Any], backward: bool = False) dict[str, Any] | None[source]#
Infer, based on the data flow, to complete the missing columns. :param rows: the data flow with the length of depth backward + depth forward :param backward: True: globally reversed; False: regular :return:
- class leads.data_persistence.analyzer.inference.SpeedInferenceBase(required_depth: tuple[int, int] = (0, 0), required_header: tuple[str, ...] = DEFAULT_HEADER)[source]#
Bases:
leads.data_persistence.analyzer.inference.InferenceInitialization
Declare the scale of data this inference requires. :param required_depth: (-depth backward, depth forward) :param required_header: the necessary header that the dataset must contain for this inference to work
- class leads.data_persistence.analyzer.inference.SafeSpeedInference[source]#
Bases:
leads.data_persistence.analyzer.inference.SpeedInferenceBaseInfer the speed based on the front wheel speed or the rear wheel speed.
v = min(fws, rws)
Initialization
Declare the scale of data this inference requires. :param required_depth: (-depth backward, depth forward) :param required_header: the necessary header that the dataset must contain for this inference to work
- class leads.data_persistence.analyzer.inference.SpeedInferenceByAcceleration[source]#
Bases:
leads.data_persistence.analyzer.inference.SpeedInferenceBaseInfer the speed based on the acceleration.
v = ∫a(t)dt
Initialization
Declare the scale of data this inference requires. :param required_depth: (-depth backward, depth forward) :param required_header: the necessary header that the dataset must contain for this inference to work
- class leads.data_persistence.analyzer.inference.SpeedInferenceByMileage[source]#
Bases:
leads.data_persistence.analyzer.inference.SpeedInferenceBaseInfer the speed based on the mileage.
v = ds/dt
Initialization
Declare the scale of data this inference requires. :param required_depth: (-depth backward, depth forward) :param required_header: the necessary header that the dataset must contain for this inference to work
- class leads.data_persistence.analyzer.inference.SpeedInferenceByGPSGroundSpeed[source]#
Bases:
leads.data_persistence.analyzer.inference.SpeedInferenceBaseInfer the speed based on the GPS ground speed.
Initialization
Declare the scale of data this inference requires. :param required_depth: (-depth backward, depth forward) :param required_header: the necessary header that the dataset must contain for this inference to work
- class leads.data_persistence.analyzer.inference.SpeedInferenceByGPSPosition[source]#
Bases:
leads.data_persistence.analyzer.inference.SpeedInferenceBaseInfer the speed based on the GPS position. This is equivalent to inferring the mileage based on GPS position and then inferring the speed based on the mileage.
v = ds/dt
Initialization
Declare the scale of data this inference requires. :param required_depth: (-depth backward, depth forward) :param required_header: the necessary header that the dataset must contain for this inference to work
- class leads.data_persistence.analyzer.inference.ForwardAccelerationInferenceBase(required_depth: tuple[int, int] = (0, 0), required_header: tuple[str, ...] = DEFAULT_HEADER)[source]#
Bases:
leads.data_persistence.analyzer.inference.InferenceInitialization
Declare the scale of data this inference requires. :param required_depth: (-depth backward, depth forward) :param required_header: the necessary header that the dataset must contain for this inference to work
- class leads.data_persistence.analyzer.inference.ForwardAccelerationInferenceBySpeed[source]#
Bases:
leads.data_persistence.analyzer.inference.ForwardAccelerationInferenceBaseInfer the forward acceleration based on the speed. Note that this is not always reliable because speed is a scalar, but forward acceleration is not. Accelerating in reverse will still be counted as forward acceleration.
a = dv/dt
Initialization
Declare the scale of data this inference requires. :param required_depth: (-depth backward, depth forward) :param required_header: the necessary header that the dataset must contain for this inference to work
- class leads.data_persistence.analyzer.inference.MileageInferenceBase(required_depth: tuple[int, int] = (0, 0), required_header: tuple[str, ...] = DEFAULT_HEADER)[source]#
Bases:
leads.data_persistence.analyzer.inference.InferenceInitialization
Declare the scale of data this inference requires. :param required_depth: (-depth backward, depth forward) :param required_header: the necessary header that the dataset must contain for this inference to work
- class leads.data_persistence.analyzer.inference.MileageInferenceBySpeed[source]#
Bases:
leads.data_persistence.analyzer.inference.MileageInferenceBaseInfer the mileage based on the speed.
s = ∫v(t)dt
Initialization
Declare the scale of data this inference requires. :param required_depth: (-depth backward, depth forward) :param required_header: the necessary header that the dataset must contain for this inference to work
- class leads.data_persistence.analyzer.inference.MileageInferenceByGPSPosition[source]#
Bases:
leads.data_persistence.analyzer.inference.MileageInferenceBaseInfer the mileage based on the speed.
s = s_0 + Δs
Initialization
Declare the scale of data this inference requires. :param required_depth: (-depth backward, depth forward) :param required_header: the necessary header that the dataset must contain for this inference to work
- class leads.data_persistence.analyzer.inference.VisualDataRealignmentByLatency(*channels: Literal[front, left, right, rear])[source]#
Bases:
leads.data_persistence.analyzer.inference.InferenceOffset the delay introduced by camera recording and video encoding so that the sensor data and the picture of the same frame match.
Initialization
Declare the scale of data this inference requires. :param required_depth: (-depth backward, depth forward) :param required_header: the necessary header that the dataset must contain for this inference to work
- class leads.data_persistence.analyzer.inference.InferredDataset(file: str, chunk_size: int = 100)[source]#
Bases:
leads.data_persistence.core.CSVDatasetInitialization
- static merge(raw: dict[str, Any], inferred: dict[str, Any]) None[source]#
Merge the inferred data to the raw data. Overwrite if conflicts. It directly alters the raw data object. :param raw: the raw data :param inferred: the difference data
- _complete(inferences: tuple[leads.data_persistence.analyzer.inference.Inference, ...], enhanced: bool, backward: bool) int[source]#
- complete(*inferences: leads.data_persistence.analyzer.inference.Inference, enhanced: bool = False, assume_initial_zeros: bool = False) int[source]#
Infer the missing values in the dataset. :param inferences: the inferences to apply :param enhanced: True: use inferred data to infer other data; False: use only raw data to infer other data :param assume_initial_zeros: True: reasonably set any missing data in the first row to zero; False: no change :return: the number of affected rows