mdx.mtmc.core.clustering module

class Clusterer(config: AppConfig)

Bases: object

Module to cluster behaviors

Parameters:

config (dict) – configuration for the app

clusterer = Clusterer(config)
cluster(behaviors: List[Behavior]) Tuple[List[MTMCObject], List[str], numpy.array]

Clusters behaviors to get MTMC objects

Parameters:

behaviors (List[Behavior]) – list of behaviors

Returns:

list of MTMC objects, list of behavior keys, and embedding array

Return type:

Tuple[List[MTMCObject],List[str],np.array]

mtmc_objects, behavior_keys, embedding_array = clusterer.cluster(behaviors)
match_online(behaviors: List[Behavior], mtmc_state_objects_plus: Dict[str, MTMCStateObjectPlus]) Tuple[List[MTMCObject], Dict[str, List[List[float]]]]

Matches behaviors in an online mode

Parameters:
  • behaviors (List[Behavior]) – list of behaviors

  • mtmc_state_objects_plus (Dict[str,MTMCStateObjectPlus]) – map from global IDs to MTMC state objects plus

Returns:

list of MTMC objects and map from global IDs to mean embeddings

Return type:

Tuple[List[MTMCObject],Dict[str,List[List[float]]]]

mtmc_objects, map_global_id_to_mean_embedding = clusterer.match_online(behaviors, mtmc_state_objects_plus)
stitch_mtmc_objects_with_state(mtmc_objects: List[MTMCObject], mtmc_state_objects_plus: Dict[str, MTMCStateObjectPlus]) List[MTMCObject]

Stitches MTMC objects with existing MTMC state objects plus

Parameters:
  • mtmc_objects (List[MTMCObject]) – list of MTMC objects

  • mtmc_state_objects_plus (Dict[str,MTMCStateObjectPlus]) – map from global IDs to MTMC state objects plus

Returns:

updated list of MTMC objects

Return type:

List[MTMCObject]

mtmc_objects = clusterer.stitch_mtmc_objects_with_state(mtmc_objects, mtmc_state_objects_plus)