ysights.viz.profiles_viz

Profile Visualization Functions

This module provides visualization functions for analyzing agent profile similarity within social networks. It helps visualize how agent interests align with their network neighbors and how this varies with network position.

Functions:
  • profile_similarity_distribution: Histogram of similarity values

  • profile_similarity_vs_degree: Scatter plot of similarity vs. node degree

  • binned_similarity_per_degree: Box plots of similarity by degree bins

Example

Visualizing profile similarity:

from ysights import YDataHandler
from ysights.algorithms import profile_topics_similarity
from ysights.viz import (
    profile_similarity_distribution,
    profile_similarity_vs_degree,
    binned_similarity_per_degree
)

ydh = YDataHandler('path/to/database.db')
network = ydh.social_network()

# Calculate similarities
similarities = profile_topics_similarity(ydh, network)

# Distribution plot
fig = profile_similarity_distribution([similarities], ['All Users'])
fig.show()

# Similarity vs degree
fig = profile_similarity_vs_degree([similarities], [network], ['All Users'])
fig.show()

# Binned by degree
fig = binned_similarity_per_degree([similarities], [network], ['All Users'])
fig.show()

See also

Functions

binned_similarity_per_degree(similarities, ...)

Plot the binned similarity values per degree for each population.

profile_similarity_distribution(...)

Plot the binned distribution of similarity values of the populations passed as a list of dictionaries.

profile_similarity_vs_degree(similarities, ...)

Plot a scatter plot of similarity values vs.

ysights.viz.profiles_viz.profile_similarity_distribution(similarities, population_names)[source]

Plot the binned distribution of similarity values of the populations passed as a list of dictionaries.

Parameters:
  • similarities (list[dict]) – list of dictionaries containing similarity values for each population

  • population_names (list[str]) – list of names corresponding to each population in the similarities list

Returns:

ysights.viz.profiles_viz.profile_similarity_vs_degree(similarities, gs, population_names)[source]

Plot a scatter plot of similarity values vs. node degree for each population.

Parameters:
  • similarities (list[dict]) – list of dictionaries containing similarity values for each population

  • gs (list) – list of graphs corresponding to each population in the similarities list

  • population_names (list[str]) – list of names corresponding to each population in the similarities list

Returns:

matplotlib figure object

ysights.viz.profiles_viz.binned_similarity_per_degree(similarities, gs, population_names, bins=10)[source]

Plot the binned similarity values per degree for each population.

Parameters:
  • similarities (list[dict]) – list of dictionaries containing similarity values for each population

  • gs (list) – list of graphs corresponding to each population in the similarities list

  • population_names (list[str]) – list of names corresponding to each population in the similarities list

  • bins – number of bins to use for the histogram

Returns:

matplotlib figure object