Skip to content

Commit

Permalink
uploading my master thesis code
Browse files Browse the repository at this point in the history
  • Loading branch information
timothy-geiger committed Jan 27, 2024
1 parent ae325b7 commit 93d55a4
Show file tree
Hide file tree
Showing 37 changed files with 5,115 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[run]
source = lung_cancer
omit = */__init__.py

[report]
exclude_lines =
@abstractmethod
31 changes: 31 additions & 0 deletions .github/workflows/flake8.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: flake8

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
flake8:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Set up Python 3.9
uses: actions/setup-python@v1
with:
python-version: 3.9

- name: Install dependencies
run: |
pip install --upgrade pip
pip install flake8
- name: Lint with flake8
run: |
flake8 .
48 changes: 48 additions & 0 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: pytest-unit-tests

on: [push]

jobs:
pytest:
name: ${{ matrix.name }}
runs-on: "${{ matrix.os }}"

strategy:
matrix:
name: [
python38-ubuntu2204,
python39-ubuntu2204,
python310-ubuntu2204
]
include:

- name: python38-ubuntu2204
python-version: 3.8
os: ubuntu-22.04

- name: python39-ubuntu2204
python-version: 3.9
os: ubuntu-22.04

- name: python310-ubuntu2204
python-version: '3.10'
os: ubuntu-22.04

steps:
- name: Checkout lung_cancer
uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
pip install --upgrade pip
pip install -e .
pip install -r requirements.txt
- name: Test with pytest
run: |
pytest tests/
89 changes: 89 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Ignore data
data/raw/*
!data/raw/.gitkeep
data/preprocessed/*
!data/preprocessed/.gitkeep

# ignore pipelines
pipelines/*
!pipelines/.gitkeep
!pipelines/README.md

.DS_Store

# the following code is used from:
# https://github.com/github/gitignore/blob/main/Python.gitignore

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Sphinx documentation
docs/_build/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

__pypackages__/

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
90 changes: 90 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
Timothy Geiger, acse-tfg22

# Lung Cancer Drug Prediction Project

This repository contains the implementation of a quantum model for predicting the reponse of lung cancer patients to drugs (TKIs). The dataset is provided by the Taipei Medical University (TMU) and includes medical details such as medical history, pathological information, genetic makeup, history of therapeutic interventions, and laboratory data like the white blood cell count. In addition to medical-specific details, the dataset also includes personal information about a patient like demographic factors, as well as insights into the patient’s personal history, e.g. smoking and drinking habits. The target variable can be one of two states: positive response to the drug or a negative response. The project focuses on the following key aspects:

- The preprocessing of the dataset.
- The development of a classical model to predict the drug response. A neural network and a random forest classifier were used as the classical methods.
- Development of a quantum model to predict the drug response of lung cancer patients to TKIs. A quantum neural network (QNN) was chosen as the quantum model.
- Comparison between the quantum model and classical models.
- Development of an eXplainable Artificial Intelligence (XAI) method for the quantum model.


## Folder Structure

1. **Python Package** (`lung_cancer`):
- Contains classes and methods to simplify the visualization of complex plots.
- Provides a data wrapper to handle data preprocessing, addressing the differing data formats required by qiskit and PyTorch.
- Includes classifier wrappers with additional methods like live plotting and cross-validation.

<br>

2. **Notebooks** (`notebooks`):
- Includes the developed python package.
- Handles the preprocessing of the dataset.
- Used for the model development of the classical and the quantum model.
- Shows a new approach that combines XAI and quantum machine learning.

<br>

3. **Pipelines** (`pipelines`):
- Contains preprocessing pipelines for both the quantum and classical models.
- Instructions in the `pipelines` folder's README guide how to obtain the pipelines.

<br>

4. **Data** (`data`):
- Contains the data provided by TMU for the project.
- Due to privacy concerns, sensitive data is not included in this GitHub repository, in accordance with ethical principles.

<br>

5. **Documentation** (`docs`):
- This directory contains a comprehensive documentation for this project.
- A pre-generated PDF version is already included.
- Instructions in the README within the `docs` directory explains how to generate a HTML documentation or create a new PDF version if needed.

<br>

6. **Tests** (`tests`):
- Contains unit tests for the Python package, covering 100% of its functionality.

<br>

7. **Workflows** (`.github/workflows`):
- Contains GitHub Actions workflows.
- These workflows automate testing, flake8 checks, and compatibility tests on various Python and Linux versions.

<br>

8. **Environment Setup**:
- The `requirements.txt` file lists all necessary packages and their versions for running the package and notebooks.
- The `environment.yml` file can be used to create an Anaconda environment using the packages from `requirements.txt`.

<br>

Please refer to the other README files in the subfolders for more informations.

## Getting Started

To use the package, follow these steps:

1. Create a conda environment using.
```shell
$ conda env create -f environment.yml
```

<br>

2. Activate the created enviroment.
```shell
$ conda activate irp-tfg
```

<br>

3. Install the developed python package using.
```shell
$ pip install -e .
```
3 changes: 3 additions & 0 deletions data/README.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Data

This folder contains two sub folders: **raw** and **preprocessed**. The original data should be placed into the raw folder. After that the preprocessing notebooks can be executed. After executing each notebook a new file will be generated in the preprocessed folder for each notebook. However, due to storage constraints and privacy, the data will not be uploaded to GitHub.
Empty file added data/preprocessed/.gitkeep
Empty file.
Empty file added data/raw/.gitkeep
Empty file.
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
57 changes: 57 additions & 0 deletions docs/README.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Documentation

This folder contains the PDF documentation. In order to regenerate this documentation again follow the following commands:

1. Create and activate the environment.

```shell
$ conda env create -f environment.yml
$ conda activate irp-tfg
$ pip install -e .
```

<br>

2. Navigate to this folder:
```shell
$ cd docs
```

<br>

3. Create a build folder if it does not yet exists:
```shell
$ mkdir build
```

<br>

4. Generate the HTML documentation:

```shell
$ sphinx-build -b html source build/html/
```

<br>

5. Generate the PDF documentation:

```shell
$ sphinx-build -b latex source build/latex/
```

<br>

6. Navigate to this folder:

```shell
$ cd build/latex
```

<br>

7. Generate the PDF documentation:

```shell
$ make
```
Binary file added docs/lung_cancer.pdf
Binary file not shown.
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)

if "%1" == "" goto help

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
Loading

0 comments on commit 93d55a4

Please sign in to comment.