Skip to content

Commit 12202f1

Browse files
authored
Merge pull request charmlab#21 from zkhotanlou/zahra/restructure-directories
Reorganize Project Structure
2 parents 0398568 + a130f33 commit 12202f1

File tree

135 files changed

+157
-650
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

135 files changed

+157
-650
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ repos:
2222
hooks:
2323
- id: clean-pytest-cache
2424
name: Remove pytest cache
25-
entry: python clean_pytest_cache.py
25+
entry: python tools/clean_pytest_cache.py
2626
language: system
2727
types: [python]
2828
- repo: local
2929
hooks:
3030
- id: check-new-methods-structure
3131
name: Check new_methods Folder Structure and Run Unit Tests
32-
entry: python folder_structure_check.py
32+
entry: python tools/folder_structure_check.py
3333
language: python
3434
types: [python]
3535
additional_dependencies:

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ This repository is inspired and built on the CARLA library. CARLA is a python li
1818
- Benchmarking (notebook): [Source](https://carla-counterfactual-and-recourse-library.readthedocs.io/en/latest/notebooks/benchmark_example.html)
1919
- Adding your own Data: [Source](https://carla-counterfactual-and-recourse-library.readthedocs.io/en/latest/examples.html#data)
2020
- Adding your own ML-Model: [Source](https://carla-counterfactual-and-recourse-library.readthedocs.io/en/latest/examples.html#black-box-model)
21-
- Adding your own Recourse Method: [Source 1](recourse_addition.md) [Source 2](https://carla-counterfactual-and-recourse-library.readthedocs.io/en/latest/examples.html#recourse-method)
21+
- Adding your own Recourse Method: [Source 1](documentation\recourse_addition.md) [Source 2](https://carla-counterfactual-and-recourse-library.readthedocs.io/en/latest/examples.html#recourse-method)
2222

2323
### Available Datasets
2424

@@ -114,15 +114,15 @@ This folder contains the implementation of all evaluation and benchmark metrics
114114

115115
### Live Site Folder
116116

117-
This folder contains the implementation of the frontend UI interface, which displays results stored in `results.csv` from executing `./run_experiment.py`.
117+
This folder contains the implementation of the frontend UI interface, which displays results stored in `results.csv` from executing `./experiments/run_experiment.py`.
118118

119119
### Models Folder
120120

121121
This folder contains all implemented models/classifiers in the repository. It also contains the model catalog class, which includes methods for loading models/classifiers and other relevant functionalities.
122122

123123
### Recourse Methods
124124

125-
This folder contains all the implemented recourse methods in the repository. Each recourse method has its own subfolder within the catalog directory (`recourse_methods/catalog`) and is implemented using the `RecourseMethod` API class` interface.
125+
This folder contains all the implemented recourse methods in the repository. Each recourse method has its own subfolder within the catalog directory (`methods/catalog`) and is implemented using the `RecourseMethod` API class` interface.
126126

127127
## Quickstart
128128

@@ -132,7 +132,7 @@ from evaluation import Benchmark
132132
import evaluation.catalog as evaluation_catalog
133133
from models.catalog import ModelCatalog
134134
from random import seed
135-
from recourse_methods import GrowingSpheres
135+
from methods import GrowingSpheres
136136

137137
RANDOM_SEED = 54321
138138
seed(RANDOM_SEED) # set the random seed so that the random permutations can be reproduced again
@@ -183,23 +183,23 @@ pip install -r .\requirements.txt
183183
python .\server.py
184184
```
185185

186-
Read more from [here](livesite_amend.md) to learn about amending the live site tool.
186+
Read more from [here](documentation\livesite_amend.md) to learn about amending the live site tool.
187187

188188
## Testing
189189

190190
Using python directly or within activated virtual environment:
191191

192192
```sh
193193
pip install -r requirements-dev.txt
194-
python -m pytest .\sanity_test.py
194+
python -m pytest .\tools\sanity_test.py
195195
```
196196

197197
## Running Experiment
198198

199199
Before running the command below, clear out all former computations from the `results.csv` file. Ensure to maintain the header (first line) of the csv file, and only delete the computation result.
200200

201201
```sh
202-
python .\run_experiment.py
202+
python -m experiments.run_experiment
203203
```
204204

205205
## Linting and Styling
@@ -253,7 +253,7 @@ Contributions of any kind are very much welcome! Take a look at the To-Do issues
253253

254254
### Reproducibility
255255

256-
- It is essential that implemented algorithms closely match the research paper they are derived from. Therefore, every implemented algorithm must be accompanied by a `reproduce.py` test file (in the corresponding folder in `recourse_methods/catalog`). This file should contain unit tests that replicate the experiments presented in the corresponding research paper, ensuring that the results obtained are consistent with those reported in the paper, within an acceptable margin of error.
256+
- It is essential that implemented algorithms closely match the research paper they are derived from. Therefore, every implemented algorithm must be accompanied by a `reproduce.py` test file (in the corresponding folder in `methods/catalog`). This file should contain unit tests that replicate the experiments presented in the corresponding research paper, ensuring that the results obtained are consistent with those reported in the paper, within an acceptable margin of error.
257257

258258
## To-Do Issues
259259

__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
from ._version import __version__
44
from .data import Data, DataCatalog
55
from .evaluation import *
6+
from .methods import RecourseMethod
67
from .models import MLModel, ModelCatalog
7-
from .recourse_methods import RecourseMethod

assignment.py renamed to assignment/assignment.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121

2222
# flake8: noqa
2323
from data.catalog import DataCatalog
24-
from logging_carla import log
24+
from methods import Dice # TO-DO: Replace with implemented recourse method
25+
from methods.processing import create_hash_dataframe
2526
from models.catalog import ModelCatalog
2627
from models.negative_instances import predict_negative_instances
27-
from recourse_methods import Dice # TO-DO: Replace with implemented recourse method
28-
from recourse_methods.processing import create_hash_dataframe
28+
from tools.logging import log
2929

3030
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "3"
3131
warnings.simplefilter(action="ignore", category=FutureWarning)
@@ -64,7 +64,7 @@ def load_setup() -> Dict:
6464
FileNotFoundError: If the experimental setup file ("experimental_setup.yaml") is not found.
6565
yaml.YAMLError: If there is an error while parsing the YAML file.
6666
"""
67-
with open("./experimental_setup.yaml", "r") as f:
67+
with open("./experiments/experimental_setup.yaml", "r") as f:
6868
setup_catalog = yaml.safe_load(f)
6969

7070
return setup_catalog["recourse_methods"]
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import os
22
import sys
33

4-
sys.path.append(os.path.dirname(os.path.realpath(__file__)))
4+
current_dir = os.path.dirname(os.path.realpath(__file__))
5+
sys.path.append(current_dir)
6+
sys.path.append(os.path.join(current_dir, "raw_data"))
7+
sys.path.append(os.path.join(current_dir, "process_data"))

0 commit comments

Comments
 (0)