Reference code for "The Effect of People Recommenders on Echo Chambers and Polarization" accepted for publication @ICWSM'22.
The repository structure has three main components:
- the folder
src
where you can find the .py scripts that implement all the ingredients of the paper (e.g.: random network model, recommenders, etc.). - The folder
Simulation_scripts
contains a unique .py file that you need to invoke to run all the experiments. - The folder
notebooks
where you can find the .ipynb notebooks to reproduce the visualizations shown in the paper.
If your goal is to reproduce the paper experiments, just follow these steps.
- Install the conda environment:
conda env create --file environment.yml
- Run
cd Simulation_scripts && python run_simulation.py
with the proper configurations. - Run the Jupyter notebook
notebooks/Network-visualizations.ipynb
.
However, PROD is a highly-customizable procedure with several reusable components:
-
At
src/recommenders.py
you can find the implementation of the people-recommender algorithms.twitter_wtf()
is the implementation of what in the paper is called SALSA.personalized_pagerank()
is the implementation of Personalized PageRank algorithm.calculate_DJ_row()
is the implementation of Directed Jaccard heuristic.biased_link_predictor()
is the implementation of what in the paper is called OBA.- All the other recommenders are either inefficient versions of previous algorithms (used for debug purposes) or other algorithms similar to the ones used (e.g.: Adamic-Adar with Directed Jaccard).
-
At
src/synthetic_generator.py
you can find the implementation of the random network model.- the main function is
generate_G_and_opinions()
which returns the networkX graph, the opinions vector, and the community assignments. If you want to reuse this module, we strongly warn that the LFR benchmark (the base algorithm to generate graphs with communities) is highly unstable, so stick with our values for the parametersavg_deg
andpower_law_coef
. The parametersmu
andconformism
tune the amount of modularity and initial homophily.
- the main function is
-
At
src/measures.py
you can find the implementation of the echo chambers/polarization measures adopted in the paper.- The functions
compute_cont_correlation_neighbors()
andcompute_RWC()
allows to compute the NCI and the RWC measures. - We left other implemented measures for those interested.
- The functions
-
At
src/utils.py
you can find auxiliary functions. -
At
src/PROD_EPISTEMIC.py
you can find the main class that allows running our PROD procedure under the Epistemological opinion update rule.- in
compute_metrics()
you can decide which metric you want to measure at the end of each round. Here, you could add your metric. Implement your function in measures.py, add it to the list, and you are done! - in
recommender_sys()
you can find how the various implemented algorithms are chosen in a PROD run. Here, you could add your recommender algorithm. Implement your function in recommenders.py, then add a specificif
statement, and you are done! - the main function is
simulate()
that you can use to execute one single PROD run and allows you to input a random seed to assess the robustness of your results.
- in
-
At
src/BCM.py
you can find the extension of PROD with the bounded confidence opinion update rule.- You can clone this module to realize your own opinion update rule. It is quite simple, (i) extend the class contained in
src/PROD_EPISTEMIC.py
and (ii) override the methodupdate_node_opinion()
as done for BCM.
- You can clone this module to realize your own opinion update rule. It is quite simple, (i) extend the class contained in