ndlib icon indicating copy to clipboard operation
ndlib copied to clipboard

Memetic Distribution Modeling

Open BradKML opened this issue 2 years ago • 5 comments

There are multiple meme models that can be assessed for information diffusion. I would consider contributing with some sample pieces of code for these models.

  • SIZ model https://doi.org/10.14419/IJAMS.V2I2.2307
  • SIR model https://doi.org/10.1016/j.apm.2011.04.035
  • SZI model https://doi.org/10.1186/s13662-020-02593-1
  • SEIR model https://doi.org/10.3934/mbe.2021263
  • SIRV model https://arxiv.org/pdf/2103.07687.pdf
  • SIRS model https://www.cise.ufl.edu/~mythai/files/diffusion.pdf
  • others included https://www.mdpi.com/2078-2489/8/4/118

The problem with all these models is that they do not factor in competing pieces of information or information mutation.

BradKML avatar Oct 31 '21 03:10 BradKML

Hi, some of them are already integrated (SEIR, SEIS). The others should be quite easy to implement: if you like to implement a few of them we can organize a CustomModels "recipe" section in the docs.

GiulioRossetti avatar Oct 31 '21 10:10 GiulioRossetti

For the SIZ model in the links the m factor of leaking is not part of it, will need to be added later https://doi.org/10.14419/IJAMS.V2I2.2307

import networkx as nx
import ndlib.models.ModelConfig as mc
import ndlib.models.CompositeModel as gc
import ndlib.models.compartments as cpm
from ndlib.viz.mpl.DiffusionTrend import DiffusionTrend
import matplotlib.pyplot as plt

%matplotlib inline # comment if ran outside a jupyter notebook

# Network generation
g = nx.erdos_renyi_graph(1000, 0.1)

# Composite Model instantiation
model = gc.CompositeModel(g)

# Model statuses
model.add_status("Susceptible")
model.add_status("Infected")
model.add_status("Stifler")
model.add_status("Emigrated")

phi = 0.05
# Compartment definition
alpha_phi = cpm.NodeStochastic(0.02*(1-phi), triggering_status="Infected")
alpha_no_phi = cpm.NodeStochastic(0.02*phi, triggering_status="Infected")
beta = cpm.NodeStochastic(0.01, triggering_status="Stifler")
gamma = cpm.NodeStochastic(0.015)
rho = cpm.NodeStochastic(0.01) 

mu = cpm.NodeStochastic(0.01) 

# Rule definition
model.add_rule("Susceptible", "Stifler", alpha_phi)
model.add_rule("Susceptible", "Infected", alpha_no_phi)
model.add_rule("Stifler", "Susceptible", rho)
model.add_rule("Infected", "Stifler", beta)
model.add_rule("Infected", "Stifler", gamma)

model.add_rule("Susceptible", "Emigrated", mu)
model.add_rule("Stifler", "Emigrated", mu)
model.add_rule("Infected", "Emigrated", mu)

# Model initial status configuration
config = mc.Configuration()
config.add_model_parameter('fraction_infected', 0.1)

# Simulation execution
model.set_initial_status(config)
iterations = model.iteration_bunch(100)
trends = model.build_trends(iterations)

viz = DiffusionTrend(model, trends)
viz.plot()

BradKML avatar Nov 01 '21 02:11 BradKML

For the SCIR model in http://cea.ceaj.org/EN/abstract/abstract33105.shtml

import networkx as nx
import ndlib.models.ModelConfig as mc
import ndlib.models.CompositeModel as gc
import ndlib.models.compartments as cpm
from ndlib.viz.mpl.DiffusionTrend import DiffusionTrend
import matplotlib.pyplot as plt

%matplotlib inline # comment if ran outside a jupyter notebook

# Network generation
g = nx.erdos_renyi_graph(1000, 0.1)

# Composite Model instantiation
model = gc.CompositeModel(g)

# Model statuses
model.add_status("Susceptible")
model.add_status("Contacted")
model.add_status("Infected")
model.add_status("Recovered")

# Compartment definition
c1 = cpm.NodeStochastic(0.02, triggering_status="Infected") # S-C
c2 = cpm.NodeStochastic(0.01) # C-I
c3 = cpm.NodeStochastic(0.015) # I-R
c4 = cpm.NodeStochastic(0.01) # S-I
c5 = cpm.NodeStochastic(0.01) # C-R

# Rule definition
model.add_rule("Susceptible", "Contacted", c1)
model.add_rule("Contacted", "Infected", c2)
model.add_rule("Infected", "Recovered", c3)
model.add_rule("Susceptible", "Infected", c4)
model.add_rule("Contacted", "Recovered", c5)

# Model initial status configuration
config = mc.Configuration()
config.add_model_parameter('fraction_infected', 0.1)

# Simulation execution
model.set_initial_status(config)
iterations = model.iteration_bunch(100)
trends = model.build_trends(iterations)

viz = DiffusionTrend(model, trends)
viz.plot()

BradKML avatar Nov 01 '21 03:11 BradKML

SIRV model is hard to do https://arxiv.org/pdf/2103.07687.pdf

BradKML avatar Nov 05 '21 17:11 BradKML

@GiulioRossetti some of the items are noted, and I hope that they can be added to documentation.

BradKML avatar Nov 05 '21 19:11 BradKML