Temporal Clustering¶
TemporalClustering models communities that evolves as time goes by.
Each temporal community clustering observation is a Clustering object, thus it inherits all properties of its specific concrete class.
Overview¶
-
class
TemporalClustering¶ -
add_clustering(clustering: object, time: object)¶ Add to the Temporal Clustering the communities observed at a given time
Parameters: - clustering – a Clustering object
- time – time of observation
-
add_matching(matching: list)¶ Add a precomputed matching of the communities.
Parameters: matching – a list of tuples [(Ti_Ca, Tj_Cb, score), … ]. Community names needs to satisfy the pattern {tid}_{cid}, where tid is the time of observation and cid is the position of the community within the Clustering object.
-
clustering_stability_trend(method: Callable[[object, object], float]) → list¶ Returns the trend for community stability. The stability index is computed for temporally adjacent clustering pairs.
Parameters: method – a comparison score taking as input two Clustering objects (e.g., NMI, NF1, ARI…) Returns: a list of floats
-
community_matching(method: Callable[[set, set], float], two_sided: bool = False) → list¶ Reconstruct community matches across adjacent observations using a provided similarity function.
Parameters: - method – a set similarity function with co-domain in [0,1] (e.g., Jaccard)
- two_sided – boolean. Whether the match has to be applied only from the past to the future (False, default) or even from the future to the past (True)
Returns: a list of tuples [(Ti_Ca, Tj_Cb, score), … ]. Community names are assigned following the pattern {tid}_{cid}, where tid is the time of observation and cid is the position of the community within the Clustering object.
-
get_clustering_at(time: object) → object¶ Returns the clustering observed at a given time
Parameters: time – the time of observation Returns: a Clustering object
-
get_community(cid: str) → list¶ Returns the nodes within a given temporal community
Parameters: cid – community id of the form {tid}_{cid}, where tid is the time of observation and cid is the position of the community within the Clustering object. Returns: list of nodes within cid
-
get_explicit_community_match() → list¶ Return an explicit matching of computed communities (if it exists)
Returns: a list of tuple [(Ti_Ca, Tj_Cb, score), … ]. Community names are assigned following the pattern {tid}_{cid}, where tid is the time of observation and cid is the position of the community within the Clustering object.
-
get_observation_ids() → list¶ Returns the list of temporal ids for the available clusterings :return: a list of temporal ids
-
has_explicit_match() → bool¶ Checks if the algorithm provided an explicit match of temporal communities
Returns: a list of tuple [(Ti_Ca, Tj_Cb, score), … ]. Community names are assigned following the pattern {tid}_{cid}, where tid is the time of observation and cid is the position of the community within the Clustering object.
-
lifecycle_polytree(method: Callable[[set, set], float] = None, two_sided: bool = False) → <Mock id='140350750723280'>¶ Reconstruct the poly-tree representing communities lifecycles using a provided similarity function.
Parameters: - method – a set similarity function with co-domain in [0,1] (e.g., Jaccard)
- two_sided – boolean. Whether the match has to be applied only from the past to the future (False, default) or even from the future to the past (True)
Returns: a networkx DiGraph object. Nodes represent communities, their ids are assigned following the pattern {tid}_{cid}, where tid is the time of observation and cid is the position of the community within the Clustering object.
-
to_json()¶ Generate a JSON representation of the TemporalClustering object
Returns: a JSON formatted string representing the object
-
Methods¶
Data transformation and IO¶
TemporalClustering.to_json() |
Generate a JSON representation of the TemporalClustering object |
TemporalClustering.get_observation_ids() |
Returns the list of temporal ids for the available clusterings :return: a list of temporal ids |
TemporalClustering.get_clustering_at(time) |
Returns the clustering observed at a given time |
TemporalClustering.add_clustering(…) |
Add to the Temporal Clustering the communities observed at a given time |
TemporalClustering.get_community(cid) |
Returns the nodes within a given temporal community |
Evaluating Node Clustering¶
TemporalClustering.clustering_stability_trend(…) |
Returns the trend for community stability. |
Matching temporal clustering¶
TemporalClustering.community_matching(…) |
Reconstruct community matches across adjacent observations using a provided similarity function. |
TemporalClustering.lifecycle_polytree(…) |
Reconstruct the poly-tree representing communities lifecycles using a provided similarity function. |