This repository contains the code, notebooks, and supporting utilities developed for a thesis project focused on the analysis of biomedical records. The workflow starts from the full dataset, isolates the natural-language notes, and evaluates multiple strategies for transforming those notes into information that can be analyzed more effectively.
The project is organized around four complementary stages:
These stages are supported by shared utilities for model interaction, prompt construction, bootstrapping, path management, and evaluation.
The repository follows a progression from raw data inspection to model-assisted analysis. First, the dataset is explored to understand its attributes and the role of the natural-language notes. Next, two alternative LLM-based strategies are tested: one aims to correct the notes, while the other extracts structured variables directly from them. Both approaches are evaluated with dedicated metrics and analysis notebooks. Finally, BERTopic is applied to the notes to support unsupervised thematic exploration.
The environment used to test the project is documented in requirements.txt, and the repository was tested with Python 3.9.6.
From the repository root, create and activate a virtual environment, then install the dependencies:
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
After the environment is ready, we suggest to choose the prompts and models you'd like to test: Correction prompts, Extraction prompts, Models.
Then, you can run the main pipeline scripts directly from the command line:
python 2_correction/2_correction_script.py
python 3_extraction/2_extraction_script.py
python utils/bootstrapping.py --task extraction
python utils/bootstrapping.py --task correction
The bootstrap command also accepts explicit paths when you want to override the defaults:
python utils/bootstrapping.py --scores-dir 3_extraction/extraction_files/llms_extraction_scores --output-path 3_extraction/extraction_files/bootstrapped_results.csv --n-bootstrap 10000
If you want to inspect or reproduce the exploratory analysis, you can re-run the notebooks in 1_dataset_exploration/ such as AccessDatasetsFiles.ipynb, dataset_attributes.ipynb, dataset_notes.ipynb, and dataset_signals.ipynb, together with the analysis notebooks in 2_correction/3_evaluation/Analysis/ and 3_extraction/3_evaluation/Analysis/ and the topic-modeling notebooks in 4_bertopic/.
The project paths are centralized in paths.py, so the scripts and notebooks can be run from the repository root without manually editing absolute paths.
The goal of the project is to determine whether automated correction, structured extraction, and topic modeling can reveal clinically relevant patterns and improve the usability of semi-structured textual records for downstream analysis.
This repository contains the code, notebooks, and supporting utilities developed for a thesis project focused on the analysis of biomedical records. The workflow starts from the full dataset, isolates the natural-language notes, and evaluates multiple strategies for transforming those notes into information that can be analyzed more effectively.
The project is organized around four complementary stages:
These stages are supported by shared utilities for model interaction, prompt construction, bootstrapping, path management, and evaluation.
The repository follows a progression from raw data inspection to model-assisted analysis. First, the dataset is explored to understand its attributes and the role of the natural-language notes. Next, two alternative LLM-based strategies are tested: one aims to correct the notes, while the other extracts structured variables directly from them. Both approaches are evaluated with dedicated metrics and analysis notebooks. Finally, BERTopic is applied to the notes to support unsupervised thematic exploration.
The environment used to test the project is documented in requirements.txt, and the repository was tested with Python 3.9.6.
From the repository root, create and activate a virtual environment, then install the dependencies:
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
After the environment is ready, we suggest to choose the prompts and models you'd like to test: Correction prompts, Extraction prompts, Models.
Then, you can run the main pipeline scripts directly from the command line:
python 2_correction/2_correction_script.py
python 3_extraction/2_extraction_script.py
python utils/bootstrapping.py --task extraction
python utils/bootstrapping.py --task correction
The bootstrap command also accepts explicit paths when you want to override the defaults:
python utils/bootstrapping.py --scores-dir 3_extraction/extraction_files/llms_extraction_scores --output-path 3_extraction/extraction_files/bootstrapped_results.csv --n-bootstrap 10000
If you want to inspect or reproduce the exploratory analysis, you can re-run the notebooks in 1_dataset_exploration/ such as AccessDatasetsFiles.ipynb, dataset_attributes.ipynb, dataset_notes.ipynb, and dataset_signals.ipynb, together with the analysis notebooks in 2_correction/3_evaluation/Analysis/ and 3_extraction/3_evaluation/Analysis/ and the topic-modeling notebooks in 4_bertopic/.
The project paths are centralized in paths.py, so the scripts and notebooks can be run from the repository root without manually editing absolute paths.
The goal of the project is to determine whether automated correction, structured extraction, and topic modeling can reveal clinically relevant patterns and improve the usability of semi-structured textual records for downstream analysis.