Hamming Distance
-
class
defSim.dissimilarity_component.HammingDistance.
HammingDistance
(exclude=[]) Bases:
defSim.dissimilarity_component.dissimilarity_calculator.DissimilarityCalculator
Implements the DissimilarityCalculator as a calculator of the Hamming distance
The class contains the attribute ‘exclude’ which accepts a list of strings with the names of agent features that should not be used to calculate between agent similarity.
-
__init__
(exclude=[]) Initialize self. See help(type(self)) for accurate signature.
-
calculate_dissimilarity
(network: networkx.classes.graph.Graph, agent1_id: int, agent2_id: int) → float Computes the Hamming Distance between two Agents, i.e. returns the proportion of features that the two agents have not in common. 1 means therefore total dissimilarity, and 0 is total overlap. Only works with categorical attributes.
- Parameters
network – The network in which the agents exist.
agent1_id – The index of the first agent.
agent2_id – The index of the agent to compare with.
:returns a float value, representing the distance between the two agents
-
calculate_dissimilarity_networkwide
(network: networkx.classes.graph.Graph, **kwargs) Calculates the distance from each agent to each other and sets that distance as an attribute on the edge between them.
- Parameters
network – The network that is modified.
-