GithubHelp home page GithubHelp logo

j535d165 / majorityvoting Goto Github PK

View Code? Open in Web Editor NEW

This project forked from heinduijf/majorityvotingcollectiveaccuracy

0.0 1.0 0.0 5.03 MB

License: MIT License

Python 6.24% HTML 91.70% Jupyter Notebook 2.07%

majorityvoting's Introduction

Majority Voting

This project concerns agent-based models and simulations of majority voting. The main goal is to investigate under which conditions majority voting succeeds in selecting the alternative that is in the best interest of the majority.

1. Setup

  1. To run the project, you first need to install the required packages
pip install -r requirements.txt
  1. To get a feel for the agent-based model, you can check out the jupyter notebook, which includes using some network visualizations, by either opening the html file NotebookWalkthrough.html or by running
jupyter-notebook NotebookWalkthrough.ipynb

Running the notebook will create several html files in the folder notebook with visualizations of agent-based models. 2. To run the simulations and generate the data, run the script

python main.py

which will create a csv file data/clean.csv, a collection of communities in the folder data/communities, and a README file with the parameter settings for the simulation in data/README.csv. 2. To generate the figures, run the script

python figures.py

which will create a folder new_figures containing all the figures. 3. To run the statistical analysis, run the script

python statistics.py

which will create several csv files in the folder stats with the results of the statistical analysis.

2. Organization of the project

The agent-based model: Community

The central class Community is defined in community.py. A Community is an agent-based model consisting of a network of agents, and it can be used to compute the estimated accuracy of a given community. The networks are generated with homophilic and preferential attachment.

Jupyter notebook: NotebookWalkthrough.ipynb

The jupyter notebook walks you through the stages of the agent-based model Community using some network visualizations. To minimalize the amount of code in the notebook, some scripts are stored in notebook.py, which is ran in one of the initial notebook cells.

Simulations: Simulation.run()

The central class Simulation and method Simulation.run() is defined in simulation.py, the method produces the csv file data/clean.csv. The method Simulation.run() runs a simulation consisting of generating number_of_communities communities and estimating the accuracy of each community by running number_of_voting_simulations voting simulations.

Figures

The script figures.py creates a folder new_figures containing all the figures. The folder generate_figures contains the scripts that generate figures. Each script in that folder is associated with one of the figures.

Statistical analysis

The script statistics.py runs the statistical analysis that generates several csv files in the folder stats. The folder stats contains scripts that generate the csv files. Each script in that folder is associated with one of the csv files.

3. Runtime issues

  1. Runtime can be an issue for Simulation.run(). To run the simulation (with parameters number_of_communities = 10 ** 5 and number_of_voting_simulations = 10 ** 5), we used a virtual machine with 16 cores and 64 GB RAM, which took approximately 5 days to finish.

  2. Runtime can also be a minor issue for two scripts in the folder generate_figures, which are also included in the script figures.py. We ran these scripts on a basic laptop (2 cores 8 GB RAM).

    1. The script figure_accuracy_homophily.py) takes approximately 10 minutes (with parameters number_of_communities=200 and number_of_voting_simulations=200).
    2. The script figure_distribution_in_degree.py takes approximately 20 minutes to finish (for 10**5 communities).

4. Licence and citation

See DOI , or check out about the Github repository or the files LICENCE.md and CITATION.cff.

majorityvoting's People

Contributors

bramkasteel avatar heinduijf avatar j535d165 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.