A tool for social network simulations in the Alvim-Knight-Valencia model.
Project description
akvmodel: A Python Tool for Social Network Simulations in the Alvim-Knight-Valencia Model
Formal models for social networks aim to capture the crucial aspects of the evolution of agents' beliefs over time, as communication occurs in a network. The Alvim-Knight-Valencia (AKV) social network model (2019) works on the dynamics of belief updates using a quantitative spectrum of belief values, and an influence graph representing the relationships between agents. Previous work on the AKV model developed belief update functions representing a range of belief update methods.
This package implements the AKV model and a catalog of its belief updates, initial configurations, and update functions from the literature, creating a general tool that incorporates a wide range of possible approaches to belief updates. In addition, we allow the AKV model to have multiple outcomes (or truth values) for the proposition used in the model. This tool facilitates future research using the AKV model without the need to reimplement it also allowing its reproducibility.
Installation
Use the package manager pip to install akvmodel.
pip install akvmodel
Usage
The full reference of the package can be found in DOCUMENTATION.md
.
import numpy as np
from akvmodel import *
# Create model with 10 agents, mildly polarized initial configuration, faintly communicating influence graph, and confirmation bias belief update.
akvmodel = AKV(
belief_state=InitialConfigurations.mildly(10),
influence_graph=InfluenceGraphs.faintly(10),
update_function=UpdateFunctions.confirmation_bias,
)
# Update the model 100 times
for _ in range(100):
akvmodel.update()
# Get polarization
p = akvmodel.get_polarization()
# Plot polarization evolution for the first outcome in the domain
plt.plot(p[0])
Full example can be found in the Jupyter Notebook example.ipynb
.
Trying the package with Docker
This project includes a Dockerfile
that builds an image with Jupyter
Notebook and necessary requirements to run the example.
Build the image:
docker build -t akvmodel-test .
Run the image:`
docker run -p 8888:8888 akvmodel-test
Open localhost:8888
on your browser, use the password test
and open the file
example.ipynb
. Changes on example.ipynb
will not be saved.
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
License
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file akvmodel-1.2.3.tar.gz
.
File metadata
- Download URL: akvmodel-1.2.3.tar.gz
- Upload date:
- Size: 22.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8b39141154aa9430024d8d0b7a9836859dfde3ed87564a9466a088d0fae6a8bf |
|
MD5 | 59cb527a52d49e23423d916208571493 |
|
BLAKE2b-256 | e1190e34b02ded9dab584df55efbdadd6bf63bb8707a27478f9413b44d4bc527 |
File details
Details for the file akvmodel-1.2.3-py3-none-any.whl
.
File metadata
- Download URL: akvmodel-1.2.3-py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 17e2f0181db5e8351e239a1a5b48f2905724f62365de0007d67e65e9e92890c8 |
|
MD5 | 6b86bf669335294a458c2a0518a1d3bc |
|
BLAKE2b-256 | 01279d8214ca04da8f2dbb550fd3f7f8720a92c4c440c4af81f8ed2d81b338eb |