Skip to content

Commit

Permalink
Update documentation and fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredleekatzman committed Oct 21, 2017
1 parent 079dee7 commit 6133ab6
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 34 deletions.
37 changes: 15 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,33 @@ For more details, see full paper [DeepSurv: Personalized Treatment Recommender S

## Installation:

### Dependencies
### From source

Theano, Lasagne (bleeding edge version), lifelines, matplotlib (for visualization) and all of their respective dependencies.
Download a local copy of DeepSurv and install from the directory:

### Installing
git clone https://github.com/jaredleekatzman/DeepSurv.git
cd DeepSurv
pip install .

You can install *DeepSurv* using
### Dependencies

pip install deepsurv
Theano, Lasagne (bleeding edge version), lifelines, matplotlib (for visualization), tensorboard_logger, and all of their respective dependencies.

from the command line.
### Running the tests

#### Dependencies
After installing, you can optionally run the test suite with

DeepSurv has been succesfully installed and tested on macOS Sierra 10.12.1 with the follow versions of Python packages:
py.test

'theano==0.8.2',
'lasagne==0.2.dev1',
'lifelines==0.9.2',
from the command line while in the repo's main directory.

### Running the tests
## Running Experiments

After installing, you can optionally run the test suite with
Experiments are run using Docker containers built off of the [floydhub](https://github.com/floydhub/dl-docker) deep learning Docker images. DeepSurv can be run on either the CPU or the GPU with nvidia-docker.

py.test
All experiments are in the `DeepSurv/experiments/` directory.

from the command line while in the module main directory.
To run an experiment, define the experiment name as an environmental variable `EXPRIMENT`and run the docker-compose file. Further details are in the `DeepSurv/experiments/` directory.

## Training a Network

Expand All @@ -62,10 +62,3 @@ You can then evaluate its success on testing data:
If you have matplotlib installed, you can visualize the training and validation curves after training the network:

deepsurv.plot_log(log)

## Running Experiments

Experiments are run using Docker containers built off of the [floydhub](https://github.com/floydhub/dl-docker) deep learning Docker images. DeepSurv can be run on either the CPU or the GPU with nvidia-docker.

To run an experiment, define the experiment name as an environmental variable `EXPRIMENT`and run the docker-compose file.

37 changes: 37 additions & 0 deletions experiments/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# DeepSurv Experiments

Experiments are run using Docker containers built off of the [floydhub](https://github.com/floydhub/dl-docker) deep learning Docker images.

### Requirements

Download and install [Docker](https://www.docker.com/community-edition#/download). If you plan to use FloydHub's GPU tag, install [nvidia-docker](https://github.com/NVIDIA/nvidia-docker).

### Experiments

To run one of the experiments from the paper, use the following command from this directory:

 EXPERIMENT=${EXPERIMENT_ID} docker-compose up --build

The following experiments are provided:

| Experiment | `${EXPERIMENT_ID} `|
| ------------- |:-------------:|
| Simulated Linear Data | `linear` |
| Simulated Nonlinear (Gaussian) Data | `gaussian` |
| Worchester Heart Attack Study (WHAS) | `whas` |
| Study to Understand Prognoses Preferences Outcomes and Risks of Treatment (SUPPORT) | `support` |
| Molecular Taxonomy of Breast Cancer International Consortium (METABRIC) | `metabric` |
| Simulated Treatment Data | `treatment` |
| Rotterdam & German Breast Cancer Study Group (GBSG) | `gbsg` |

The hyper-parameters for each experiment are in this repo's directory: `DeepSurv/experiments/deepsurv/models/`

For more details on each experiment, reference [DeepSurv: Personalized Treatment Recommender System Using A Cox Proportional Hazards Deep Neural Network](http://arxiv.org/abs/1606.00931).

#### Using GPU

If you have nvidia-docker installed, you can run DeepSurv experiments using your GPU. To do so change the tag in the first line of your experiment's docker file.

For example, to run the simulated linear data experiment with the GPU change the first line the file `./deepsurv/Docker.linear` to:

FROM floydhub/dl-docker:gpu
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ h5py==2.7.0
lifelines==0.9.4
logger==1.4
Optunity==1.1.1
tensorboard-logger==0.0.3
tensorboard_logger==0.0.3
lasagne==0.2.dev1
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
long_description = file.read()

setup(name='deepsurv',
version='0.1.0',
version='0.2.0',
description='Deep Cox Proportional Hazards Network for deep learning and survival analysis.',
keywords = "survival analysis deep learning cox regression",
url='https://github.com/jaredleekatzman/DeepSurv',
Expand All @@ -24,6 +24,7 @@
'theano==0.8.2',
'lasagne==0.2.dev1',
'lifelines==0.9.2',
'tensorboard_logger==0.0.3'
],
# test_suite = 'nose.collector',
# test_require = ['nose','lasagne','theano']
Expand Down
14 changes: 4 additions & 10 deletions tests/test_deepsurv.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ def test_deepsurv_initialize_dropout(self):
network = DeepSurv(dropout = 0.5, **self.hyperparams)
assert len(network.hidden_layers) == 2 * len(self.hidden_layers_sizes) + 1

def test_deepsurv_initialize_standardize_layer(self):
network = DeepSurv(standardize = True, **self.hyperparams)
assert len(network.hidden_layers) == len(self.hidden_layers_sizes) + 3

class TestDeepSurvTrain():

@classmethod
Expand All @@ -65,12 +61,10 @@ def setup_class(self):
self.network = network

def test_train(self):
# Test if network computes nan for any values
assert self.log.has_key('train') == True
assert numpy.any(numpy.isnan(self.log['train'])) == False

assert self.log.has_key('valid') == True
assert numpy.any(numpy.isnan(self.log['valid'])) == False
# Test if network has undefined parameters
assert self.log.has_key('best_params') == True
params_is_nan = [is_nan for params in self.log['best_params'] for is_nan in numpy.isnan(params.flatten())]
assert numpy.any(params_is_nan) == False

def test_network_predict_risk(self):
risk = self.network.predict_risk(self.test['x'])
Expand Down

0 comments on commit 6133ab6

Please sign in to comment.