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
Metadata
Release files for akvmodel 1.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| akvmodel-1.2.3.tar.gz | 22.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| akvmodel-1.2.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 29.3 kB
Release files / akvmodel-1.2.3.tar.gz
| Download URL | akvmodel-1.2.3.tar.gz |
|---|---|
| Size | 22.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8b39141154aa9430024d8d0b7a9836859dfde3ed87564a9466a088d0fae6a8bf
|
|
BLAKE2b-256 checksum How to use checksums |
e1190e34b02ded9dab584df55efbdadd6bf63bb8707a27478f9413b44d4bc527
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.19
|
Release files / akvmodel-1.2.3-py3-none-any.whl
| Download URL | akvmodel-1.2.3-py3-none-any.whl |
|---|---|
| Size | 7.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
17e2f0181db5e8351e239a1a5b48f2905724f62365de0007d67e65e9e92890c8
|
|
BLAKE2b-256 checksum How to use checksums |
01279d8214ca04da8f2dbb550fd3f7f8720a92c4c440c4af81f8ed2d81b338eb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.19
|