How I used AI to Detect Breast Cancer in Less than 100 Lines of Code

What are Neural Networks?

The neurons/nodes are the circles and the weights are the lines connecting them

The Program

Input Data

Any neural network requires input data, this is what’s used to perform predictions, train the network, and test its accuracy.

  1. Radius (mean of distances from the centre to points on the perimeter)
  2. Texture (standard deviation of grey-scale values)
  3. Perimeter
  4. Area
  5. Smoothness (local variation in radius lengths)
  6. Compactness (perimeter² / area — 1.0)
  7. Concavity (severity of concave portions of the contour)
  8. Concave points (number of concave portions of the contour)
  9. Symmetry
  10. Fractal dimension (“coastline approximation” — 1)
This is what breast biopsy tissue looks like

Network Architecture

Once we have the dataset separated and data files set up, we can start thinking about the network’s design.

Training the Network

Now that we have created the neural network we have to train it. Training a neural network means teaching it to recognise patterns in a dataset and output the correct predictions.


To test our neural network we want to perform predictions on data it hasn’t seen before. This is when we use the data we separated out earlier.

The Future

To this day, 1 in 36 women is still destined to die from breast cancer! We need much more advancement in the medical field when it comes to developing better ways to detect and treat diseases. AI offers the potential to do that, and with more research and innovation it has the potential to make a significant impact in the healthcare industry.

  1. Clap this article
  2. Share it with others who might benefit
  3. Connect with me on LinkedIn



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store