Thanks for attending my grand rounds!
Click here to download a Powerpoint of Presentation
Neural Network Playground
Click Here to open the neural network playground.
This is how I demonstrated the benefits of additional layers of a neural network to predict a hypothetical set of hypotensive patients based on EF and volume of saline received.The model allows you to choose a test dataset, the inputs into the model, the number of hidden layers of neurons, as well as the number of neurons per layer. It also has several other adjustable parameters which we didn’t discuss –
Learning Rate: This reflects how quickly the model will converge on a solution, or how big of a change will happen to the model each time the current error is calculated. However, when the learning rate is too large, instead of converging on a solution, the algorithm will overreact and may generate increasingly incorrect models.
Activation: This refers to the ‘threshold’ function that is applied to the weighted inputs to each neuron to generate the output. These are just different ways to model the ‘all-or-none’ conduction of neurons, where the input must reach a certain threshold before a signal is generated.Regularization: Given enough features, as you continue to train your neural network model, eventually you expect to gain near perfect accuracy for your training dataset. However, this is in part because the model can begin to recognize noise in the data instead of features that help predict the outcome you’re interested in. For example, suppose you train a model to recognize dysmorphic faces to identify children with a genetic disorder. At first the model may recognize important features common to many patients with your genetic disorder of interest, such as microcephaly or micrognathia. However, as you continue to train your model, it will begin to recognize features associated with individual images in the training data set that are unrelated to the disorder – perhaps the presence of an unrelated mole, or the lighting in one individual picture.
Regularization provides an incentive for your model to use the lowest weights possible for every connection, so that only true features that are consistent across multiple images will be recognized by your model.
Ratio of Training to Test Data: It is traditional to set aside a portion of the data used to train your model as ‘test data’, so that you can assess the validity of your model on data that it has never been exposed to in training. Generally 10-20% of the data is used for validation, depending on the size of your dataset.
Noise: The test data listed on this neural network playground follow an exact pattern, but by increasing the noise parameter you can create a more realistic ‘messy’ dataset, where it is impossible to precisely classify every element of the dataset.
Batch Size: Refers to how many of the data points are used in each round of training the model.
Using transfer learning to classify images
First, download and install python version 3.6 for Windows / Mac
You can verify your installation is working by opening up the command line – on windows you can do this by pressing ⊞ Win + R to bring up the run window and then typing cmd
You can test to make sure your python installation is working by running python version 3.6 from your command line with the command
py -3.6 --version
Install some needed modules with the commands
py -3.6 -m pip --install numpy
py -3.6 -m pip --install tensorflow
py -3.6 -m pip --install tensorflow-hub
Download this code and test data
First you need to train the model on the white blood cell images. Unzip the downloaded folder above, press shift + right click inside the folder, and select “Open Command Window Here”.
Inside the command window, type:
py -3.6 retrainBMP.py --image_dir=WBCs
Your model should now be training! To test the results on a new image, type:
py -3.6 label_image.py --image=WBCs/neutrophil/1.bmp
You will get a list of percentages associated with each image class!
If you’re interested in learning more, this code was largely based off of this tutorial. Read more to discover how to fine tune your model and training data so you can get a model that’s over 90% accurate!
My database of white blood cell images is modified from the LISC database. Any research published using this database should include the following citation:
Rezatofighi, S.H., Soltanian-Zadeh, H.: Automatic recognition of five types of white blood cells in peripheral blood. Computerized Medical Imaging and Graphics 35(4) (2011) 333–343.
Using transfer learning to classify images (Mac)
First, download and install python version 3.6 for Windows / Mac
You can verify your installation is working by opening up python in terminal (Go to spotlight and type ‘terminal’). Then run the following:
python3.6 --version
Navigate to the Applications folder, then to the ‘Python 3.6’ folder, and run “Install Certificates.command”.
Install some needed modules with the commands
python3.6 -m pip install numpy
python3.6 -m pip install tensorflow
python3.6 -m pip install tensorflow-hub
Download this code and test data
First you need to train the model on the white blood cell images. Unzip the downloaded folder above, then navigate to the folder using the terminal. If the folder is inside your ‘Downloads’ folder, you can type the following to navigate to the folder.
cd downloads/WBCs
Inside the terminal, type:
python3.6 retrainBMP.py --image_dir=WBCs
Your model should now be training! To test the results on a new image, type:
python3.6 label_image.py --image=WBCs/neutrophil/1.bmp
You will get a list of percentages associated with each image class!
If you’re interested in learning more, this code was largely based off of this tutorial. Read more to discover how to fine tune your model and training data so you can get a model that’s over 90% accurate!
My database of white blood cell images is modified from the LISC database. Any research published using this database should include the following citation:
Rezatofighi, S.H., Soltanian-Zadeh, H.: Automatic recognition of five types of white blood cells in peripheral blood. Computerized Medical Imaging and Graphics 35(4) (2011) 333–343.
Modeling Breast Cancer Survival with SEER Data
Download the Weka 3 Machine Learning Tool
Run the Weka 3 tool after installing, and choose “Explorer”
In the Preprocess tab, open a the file you wish to analyze. You can see how Weka can analyze comma separated value files with this test data file (must extract before selecting with Weka). In this training set of data, you have two input values, and a label. If both inputs are positive, or both are negative, the label is 1. Otherwise, the label is 0. This is hard to model with traditional regression, but easy with neural networks.
In the preprocess tab, choose “Open file…”, and select test.csv. Make sure to click “Invoke options dialog”.
In the options dialog, make column 3 a nominal attribute (in this case, indicating that the label is binary), and make column 1 and 2 numeric attributes. Since logistic regression is used for binary classification, we have to make column 3 binary in order to use a simple logistic regression.
In the Classify Tab, hit the “Choose” button to select your model, and navigate to the Simple Logistic model.
The words “SimpleLogistic” should now show up next to the Choose button. If you click on the word “SimpleLogistic” you can edit parameters of the model, but let’s keep the defaults for now. Under Test options, choose “Use training set”, and select the column “Label” from the dropdown menu to indicate we want to predict the data in the “Label” column of the test.csv file. Hit Start to generate a prediction.
We can see that the logistic regression classified 50% of the test data correctly. We can visualize this data better by right clicking on our trained model in the bottom left, and selecting Visualize classifier errors.
Now plot the Train1 column on the x-axis, and Train2 column on the y-axis. We can see the square boxes indicating that all the data when X is positive is misclassified.
Can we do better with a neural network? Select Multilayer Perceptron (another name for a neural network) from the Choose menu.
We can change the parameters for the model by clicking the “MultilayerPerceptron”, but lets leave these as default for now. Again, hit the start button to train the model.
We can see from the summary that the classification was much more successful! Again, lets visualize the results.
We can see that nearly all values are correctly classified.
You can request access to the SEER data here. You can choose to download the SEER data as text files. If you open the text file in excel, you can convert it to a CSV. First, you need to select “Text to columns”.
Choose fixed width columns.
Finally, you have to go through the tedious task of choosing column widths that match up with the data file description included with the SEER data.
After setting the column widths, hit finish, and save the file as a .csv file. You can now load it with Weka to analyze! You may need to edit the columns to represent the variables you are interested in. For example, survival in SEER is listed in months, so if you want to generate a logistic regression on 5 year survival, you need to create a new column that lists a 1 if survival >= 60 months, and a 0 otherwise.