OutputMeasures

class defSim.tools.OutputMeasures.AttributeReporter(feature: Optional[str] = None)

Bases: defSim.tools.CreateOutputTable.OutputTableCreator

__init__(feature: Optional[str] = None)

Initialize self. See help(type(self)) for accurate signature.

create_output(network: networkx.classes.graph.Graph, **kwargs)

This function will output a single row of a dataframe where the columns are user-given agent-features and column values contain a list of all the agents’ values on the given feature.

Parameters
  • network – A NetworkX object

  • feature – The name of the feature to output

Returns

A list of feature values for each agent

label = 'AttributeReporter'
class defSim.tools.OutputMeasures.AverageDistanceReporter(**kwargs)

Bases: defSim.tools.CreateOutputTable.OutputTableCreator

create_output(network: networkx.classes.graph.Graph, **kwargs)

Output the average feature distance across all edges. Based on calculated distances in the network (so based on whatever distance measure was specified in the simulation).

Parameters

network – A NetworkX object

Returns

Average distance (float)

label = 'AverageDistance'
class defSim.tools.OutputMeasures.AverageOpinionReporter(feature: str = 'f01')

Bases: defSim.tools.CreateOutputTable.OutputTableCreator

__init__(feature: str = 'f01')

Initialize self. See help(type(self)) for accurate signature.

create_output(network: networkx.classes.graph.Graph, **kwargs)

Output the average opinion on a feature across all agents.

Parameters

network – A NetworkX object

Returns

Average opinion (float)

label = 'AverageOpinion'
class defSim.tools.OutputMeasures.ClusterFinder(cluster_dissimilarity_threshold: float = 0, strict_zones: bool = False)

Bases: defSim.tools.CreateOutputTable.OutputTableCreator

__init__(cluster_dissimilarity_threshold: float = 0, strict_zones: bool = False)

Initialize self. See help(type(self)) for accurate signature.

create_output(network: networkx.classes.graph.Graph, **kwargs)

Finds the size and number of cultural regions, zones, or clusters present in the graph. Following Axelrod (1997) regions are defined as a set of connected nodes with an identical attribute profile. Zones are sets of connected nodes that have some attribute overlap, such that change is still possible.

Parameters
  • network – A NetworkX object

  • cluster_dissimilarity_threshold (float=0) – Threshold \(\in [0,1]\) that defines the maximal allowed dissimilarity between two agents for them to be considered to belong to the same cluster. A value of 0 returns the strict number of regions

  • strict_zones – If true, cluster_dissimilarity_threshold is neglected and strict zones are returned (only the links with dissimilarity != 1 are preserved)

Returns

A list with sizes of the retrieved clusters

label = 'ClusterFinder'
class defSim.tools.OutputMeasures.CoverageReporter(feature: str = 'f01')

Bases: defSim.tools.CreateOutputTable.OutputTableCreator

__init__(feature: str = 'f01')

Initialize self. See help(type(self)) for accurate signature.

create_output(network: networkx.classes.graph.Graph, **kwargs)

Report coverage for nondiscrete features, following [Bramson2016]. Its goal is to report the proportion of distinct opinion positions held by the agents in the model. To find this proportion, each opinion position receives a bin (or ‘halo’) around the position of size 1 over the number of agents in the network. Coverage is then defined as proportion of the total area that is covered by the bins. Coverage is maximized if all agents hold unique positions and bins have zero overlap. The minimum coverage value is equal to 1 divided by the number of agents in the network.

Parameters

network – A NetworkX object

Returns

Coverage (float)

label = 'Coverage'
class defSim.tools.OutputMeasures.DispersionReporter(feature: str = 'f01')

Bases: defSim.tools.CreateOutputTable.OutputTableCreator

__init__(feature: str = 'f01')

Initialize self. See help(type(self)) for accurate signature.

create_output(network: networkx.classes.graph.Graph, **kwargs)

Report the amount of dispersion defined as the average absolute deviation from the mean on a given feature. The implementation mirrors that from [Bramson2016]

Parameters

network – A NetworkX object

Returns

Dispersion (float)

label = 'Dispersion'
class defSim.tools.OutputMeasures.SpreadReporter(feature: str = 'f01')

Bases: defSim.tools.CreateOutputTable.OutputTableCreator

__init__(feature: str = 'f01')

Initialize self. See help(type(self)) for accurate signature.

create_output(network: networkx.classes.graph.Graph, **kwargs)

Report the spread defined as the difference between the maximum and minimum value on a given feature.

Parameters

network – A NetworkX object

Returns

Spread (float)

label = 'Spread'

References

Bramson2016(1,2)

Bramson, A., Grim, P., Singer, D. J., Fisher, S., Berger, W., Sack, G., & Flocken, C. (2016). Disambiguation of social polarization concepts and measures. *The Journal of Mathematical Sociology, 40*(2), 80–111. https://doi.org/10.1080/0022250X.2016.1147443