Optimal Sub-Pattern Assignment (OSPA) Metric
- class stonesoup.metricgenerator.ospametric.GOSPAMetric(p: float, c: float, measure: Measure = Euclidean(mapping=None, mapping2=None))[source]
Bases:
MetricGenerator
Computes the Generalized Optimal SubPattern Assignment (GOPSA) metric for two sets of
Track
objects. This implementation of GOSPA is based on the auction algorithm.The GOPSA metric is calculated at each time step in which a
Track
object is present- Reference:
[1] A. S. Rahmathullah, A. F. García-Fernández, L. Svensson, Generalized optimal sub-pattern assignment metric, 2016, [online] Available: http://arxiv.org/abs/1601.05585.
- Parameters
p (
float
) – 1<=p<infty, exponent.c (
float
) – c>0, cutoff distance.measure (
Measure
, optional) – Distance measure to use. DefaultEuclidean()
- measure: Measure
Distance measure to use. Default
Euclidean()
- compute_metric(manager)[source]
Compute the metric using the data in the metric manager
- Parameters
manager (
MetricManager
) – contains the data to be used to create the metric(s)- Returns
metric – Containing the metric information. The value of the metric is a list of metrics at each timestamp
- Return type
list
Metric
- static extract_states(object_with_states)[source]
Extracts a list of states from a list of (or single) objects containing states. This method is defined to handle
StateMutableSequence
andState
types.- Parameters
object_with_states (object containing a list of states) – Method of state extraction depends on the type of the object
- Return type
list of
State
- compute_over_time(measured_states, truth_states)[source]
Compute the GOSPA metric at every timestep from a list of measured states and truth states.
- Parameters
measured_states (List of states created by a filter) –
truth_states (List of truth states to compare against) –
- Returns
metric (
TimeRangeMetric
covering the duration that states)exist for in the parameters. metric.value contains a list of metrics
for the GOSPA metric at each timestamp
- compute_assignments(cost_matrix, max_iter)[source]
Compute assignments using Auction Algorithm.
- Parameters
cost_matrix (Matrix (size mxn) that denotes the cost of assigning) – mth truth state to each of the n measured states.
max_iter (Maximum number of iterations to perform) –
- Returns
truth_to_measured (np.ndarray) – Vector of size m, which has indices of the measured objects or ‘-1’ if unassigned.
measured_to_truth (np.ndarray) – Vector of size n, which has indices of the truth objects or ‘-1’ if unassigned.
opt_cost (float) – Scalar value of the optimal assignment
- compute_cost_matrix(track_states, truth_states, complete=False)[source]
Creates the cost matrix between two lists of states
This distance measure here will return distances minimum of either
c
or the distance calculated fromMeasure
.
- compute_gospa_metric(measured_states, truth_states)[source]
Computes GOSPA metric between measured and truth states.
- Parameters
- Returns
gospa_metric (Dictionary containing GOSPA metric for alpha = 2.) – GOSPA metric is divided into four components: 1. distance, 2. localisation, 3. missed, and 4. false. Note that distance = (localisation + missed + false)^1/p
truth_to_measured_assignment (Assignment matrix.)
- class stonesoup.metricgenerator.ospametric.OSPAMetric(p: float, c: float, measure: Measure = Euclidean(mapping=None, mapping2=None))[source]
Bases:
GOSPAMetric
Computes the Optimal SubPattern Assignment (OPSA) distance [1] for two sets of
Track
objects. The OSPA distance is measured between two point patterns.The OPSA metric is calculated at each time step in which a
Track
object is present- Reference:
[1] A Consistent Metric for Performance Evaluation of Multi-Object Filters, D. Schuhmacher, B. Vo and B. Vo, IEEE Trans. Signal Processing 2008
- Parameters
p (
float
) – norm associated to distancec (
float
) – Maximum distance for possible associationmeasure (
Measure
, optional) – Distance measure to use. DefaultEuclidean()
- compute_over_time(measured_states, truth_states)[source]
Compute the OSPA metric at every timestep from a list of measured states and truth states
- Parameters
- Returns
Covering the duration that states exist for in the parameters. Metric.value contains a list of metrics for the OSPA distance at each timestamp
- Return type
- compute_OSPA_distance(track_states, truth_states)[source]
Computes the Optimal SubPattern Assignment (OPSA) metric for a single time step between two point patterns. Each point pattern consisting of a list of
State
objects.The function \(\bar{d}_{p}^{(c)}\) is the OSPA metric of order \(p\) with cut-off \(c\). The OSPA metric is defined as:
\[\begin{equation*} \bar{d}_{p}^{(c)}({X},{Y}) := \Biggl( \frac{1}{n} \Bigl({min}_{\substack{ \pi\in\Pi_{n}}} \sum_{i=1}^{m} d^{(c)}(x_{i},y_{\pi(i)})^{p}+ c^{p}(n-m)\Bigr) \Biggr)^{ \frac{1}{p} } \end{equation*}\]- Parameters
- Returns
The OSPA distance
- Return type