The aim of this practice is to detect communities in an Amazon item network, where communities are represented by the product category, and two products are connected if they have been repeatedly purchased together. In this paper, two methods for community detection will be compared: the Leiden algorithm and multi-objective genetic algorithms.
To install the necessary dependencies for this project, ensure you have Python 3.11.4 or higher installed. Then, follow these steps:
- Clone this repository to your local machine using:
$ git clone https://github.com/SamuReyes/GeneticCommunities
- Change to the cloned repository directory:
$ cd GeneticCommunities
- Install the dependencies using
pip
. It is recommended to do this within a virtual environment to avoid dependency conflicts. You can create a virtual environment usingvenv
:
$ python -m venv venv
$ source venv/bin/activate # On Windows, use: venv\Scripts\activate
- With the virtual environment activated, install the dependencies by running:
$ pip install -r requirements.txt
By following these steps, you will have all the necessary dependencies installed and be ready to run the project.
This project is primarily interacted with through Jupyter Notebooks, which provide a user-friendly interface for running various functions and algorithms.
The main.ipynb
notebook is the central file where you can perform a variety of tasks:
- Execute the Leiden Algorithm: Run the Leiden algorithm for community detection.
- Launch Genetic Algorithms: Initiate genetic algorithms for obtaining communities distributions.
- Compare Results with Ground Truth: Analyze and compare the results of the algorithms with ground truth data.
- Metric Evaluation: Evaluate different metrics to measure the performance and effectiveness of the algorithms.
Each section within the notebook is well-documented, providing clear instructions and explanations on how to execute and utilize each function.
In addition to the main notebook, there is a hp_tunning.ipynb
notebook specifically designed for hyperparameter tuning of the genetic algorithms.
To start using these notebooks:
- Ensure you have followed the Installation of Dependencies section to set up your environment.
- Open the desired notebook (
main.ipynb
orhp_tunning.ipynb
) in Jupyter Notebook or JupyterLab. - Follow the instructions and documentation within each notebook to execute different functions and algorithms.
These notebooks provide a comprehensive guide and hands-on approach to understanding and utilizing the capabilities of this project.