/exercise-breast-cancer

Python feed-forward neural network to predict breast cancer. Trained using stochastic gradient descent in combination with backpropagation.

Primary LanguagePythonMIT LicenseMIT

Basic implementation of a neural network in python

Installation

When using virtualenv, create a new environment and activate it with the following commands:

virtualenv .
. bin/activate

To install the dependencies using pip run:

pip install -r requirements.txt

Usage

The usage is currently quite limited. The provided dataset res/breast-cancer-wisconsin.data is hardcoded. A different dataset can't be used without modifying the code. The application can be started using the command:

python3 breast_cancer.py

About the application

The application will initialize a multilayered perceptron network. This network contains an input layer of 9 neurons, followed by a hidden layer of another 9 neurons and an output layer of 1 neuron. The network will be trained using the backpropagation algorithm (SGD) wich is implemented completely using only raw python and numpy arrays and numpy array operations.

Thanks

This script is the result of an attempt to learn how neural networks work and can be trained. The sources used to obtain this information are:

  • The CS224d course, specifically lecture 6. (lecture , notes)
  • A tutorial by Matt Mazur which explains the required calculations in a different way (link)
  • Another Python/Numpy implementation by hdmetor.