This repository contains the codebase for the FairTree experiments. To ensure the project works seamlessly, you need to set the PYTHONPATH environment variable properly.
This repository uses constants.py for local configuration. This file is ignored by Git, so changes remain local to your system.
To set it up:
-
Copy the template file:
cp constants.py.template constants.py
-
Edit
constants.pyand replace placeholder values with your local path information:LOCAL_PATH = "/your/local/path"
The PYTHONPATH environment variable must point to the root directory of this repository and the FairTree subdirectory. This allows Python to locate the necessary modules when running scripts or importing them.
After cloning the repository, follow these steps:
-
Determine the Full Path to the Repository
ReplacePATH_TO_REPOin the instructions below with the absolute path to where you cloned this repository.Example: If you cloned the repository to
/home/user/projects/FairTreeExperiments, use/home/user/projects/FairTreeExperimentsas thePATH_TO_REPO. -
Set PYTHONPATH
To temporarily set PYTHONPATH for the current session:
export PYTHONPATH=PATH_TO_REPO:PATH_TO_REPO/FairTreeTo make it permanent (persisting across sessions), add the following line to your ~/.bashrc (or ~/.bash_profile on macOS):
export PYTHONPATH=PATH_TO_REPO:PATH_TO_REPO/FairTreeAfter adding the line, reload your shell configuration:
source ~/.bashrcset -x PYTHONPATH PATH_TO_REPO PATH_TO_REPO/FairTreeTo make it permanent (persisting across sessions), edit your Fish configuration file (~/.config/fish/config.fish) and add the following line:
set -x PYTHONPATH PATH_TO_REPO PATH_TO_REPO/FairTreeAfter editing, reload the configuration:
source ~/.config/fish/config.fishTo ensure PYTHONPATH is set correctly, run the following command in your shell:
echo $PYTHONPATHYou should see output similar to:
/home/user/projects/FairTreeExperiments:/home/user/projects/FairTreeExperiments/FairTreeFor running a single run of the one-tree or dual-tree approach, you have to use algos_one_tree/method.py or algos_two_trees/method.py.
The hyperparameter search can be performed using the script run_hp_opt.sh in the corresponding directory.
In the directory evaluation, you can find the python files that retrain the models for the best found hyperparameters, i.e., one_tree_opt.py, two_tree_opt.py, and rel_threshold_optimizer_opt.py.
Be careful to pass the correct paths as arguments.