tbp.monty.frameworks.models.evidence_matching.feature_evidence#

tbp.monty.frameworks.models.evidence_matching.feature_evidence.calculator#

class DefaultFeatureEvidenceCalculator[source]#

Bases: object

classmethod calculate(channel_feature_array: np.ndarray, channel_feature_order: list[str], channel_feature_weights: dict, channel_query_features: dict, channel_tolerances: dict) np.ndarray[source]#

Calculate the feature evidence for all nodes stored in a graph.

For each node, compares the stored features against the observed query features and returns a score in [0, 1]: 1 for a perfect match, decaying to 0 once the difference exceeds the per-feature tolerance. Nodes with missing stored values for a feature receive NaN evidence.

Parameters:
  • channel_feature_array – Stored features for every node in the graph, shape (n_nodes, n_columns). Columns follow the layout given by channel_feature_order.

  • channel_feature_order – Feature names in the order they appear across the columns of channel_feature_array.

  • channel_feature_weights – Per-feature weights used to combine per-column evidence into a single per-node score.

  • channel_query_features – Observed feature values to compare against the stored features, keyed by feature name.

  • channel_tolerances – Per-feature tolerance, the largest difference that still produces non-zero evidence.

Returns:

The feature evidence for all nodes, shape (n_nodes,).

CATEGORICAL_FEATURES = frozenset({'object_id'})#
CIRCULAR_FEATURES = frozenset({'hsv'})#
CIRCULAR_RANGE = 1#
SKIP_FEATURES = frozenset({'pose_fully_defined', 'pose_vectors'})#
class FeatureEvidenceCalculator(*args, **kwargs)[source]#

Bases: Protocol

__init__(*args, **kwargs)#
static calculate(channel_feature_array: np.ndarray, channel_feature_order: list[str], channel_feature_weights: dict, channel_query_features: dict, channel_tolerances: dict) np.ndarray[source]#

tbp.monty.frameworks.models.evidence_matching.feature_evidence.scorer#

class DefaultFeatureEvidenceScorer(graph_memory: EvidenceGraphMemory, feature_weights: dict, tolerances: dict, feature_evidence_calculator: type[FeatureEvidenceCalculator] = <class 'tbp.monty.frameworks.models.evidence_matching.feature_evidence.calculator.DefaultFeatureEvidenceCalculator'>, feature_evidence_increment: int = 1, features_for_matching_selector: type[FeaturesForMatchingSelector] = <class 'tbp.monty.frameworks.models.evidence_matching.features_for_matching.selector.DefaultFeaturesForMatchingSelector'>) None[source]#

Bases: FeatureEvidenceScorer

Default scorer that calculates the feature evidence for a given channel.

The feature evidence is a value between 0 and 1 that indicates how well the observed features match the stored features. If the channel is used for matching, the evidence is calculated by the feature evidence calculator and multiplied by the feature evidence increment. Otherwise, all zeros are returned.

__init__(graph_memory, feature_weights, tolerances, feature_evidence_calculator=<class 'tbp.monty.frameworks.models.evidence_matching.feature_evidence.calculator.DefaultFeatureEvidenceCalculator'>, feature_evidence_increment=1, features_for_matching_selector=<class 'tbp.monty.frameworks.models.evidence_matching.features_for_matching.selector.DefaultFeaturesForMatchingSelector'>)[source]#

Initializes the DefaultFeatureEvidenceScorer.

Parameters:
  • graph_memory – The graph memory to read graphs from.

  • feature_weights – How much should each feature be weighted when calculating the evidence update for hypothesis. Weights are stored in a dictionary with keys corresponding to features (same as keys in tolerances).

  • tolerances – How much can each observed feature deviate from the stored features to still be considered a match.

  • feature_evidence_calculator – Calculator that calculates feature evidence for all nodes.

  • feature_evidence_increment – Feature evidence (between 0 and 1) is multiplied by this value before being added to the overall evidence of a hypothesis. This factor is only multiplied with the feature evidence (not the pose evidence as opposed to the present_weight). Defaults to 1.

  • features_for_matching_selector – Selector that selects if features should be used for matching. Defaults to the default selector.

class FeatureEvidenceScorer(*args, **kwargs)[source]#

Bases: Protocol

A scorer that calculates the feature evidence for a given channel.

TODO: “FeatureEvidenceScorer” is not a great name and should be considered a placeholder. The name was created during refactoring of common functionality to improve dependency injection in hypotheses updater and displacer code. Once the refactoring is complete and dependency injection improved, we should reconsider whether this functionality should be bundled together in a single class and if so, what a better name would be.

__init__(*args, **kwargs)#