ash_model.measures.star_profile_entropy¶
- ash_model.measures.star_profile_entropy(h, node_id, tid, method='aggregate')[source]¶
Returns the entropy of the star profile of a node, i.e., the entropy of the attribute values for each attribute in the profiles of the nodes in the star of the given node. If method is ‘aggregate’, it is computed by first aggregating each hyperedge into a single profile (see hyperedge_aggregate_node_profile). Else if method is ‘collapse’, all the node’s neighbors are considered.
- Parameters:
- Returns:
A dictionary with the entropy of each attribute
- Return type:
Examples
Compute the star-profile entropy for a node (aggregate method) on tid=0 with the dataset above:
>>> import numpy as np, networkx as nx >>> from ash_model.utils.networkx import from_networkx_maximal_cliques_list >>> Gs = [nx.barabasi_albert_graph(100, 3, seed=i) for i in range(10)] >>> rng = np.random.default_rng(42) >>> for G in Gs: ... for n in G.nodes(): ... G.nodes[n]['color'] = 'red' if rng.integers(0, 2) == 0 else 'blue' >>> h = from_networkx_maximal_cliques_list(Gs) >>> tid = 0 >>> node0 = next(iter(h.nodes(start=tid, end=tid))) >>> star_profile_entropy(h, node0, tid, method='aggregate') {'color': np.float64(0.7706290693639405)}