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 cdlib.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

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.

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(method)

Returns the trend for community stability.