Breast Cancer Detection Using Machine Learning

randerson112358
9 min readJul 4, 2019

In this article I will show you how to create your very own machine learning python program to detect breast cancer from data. Breast Cancer (BC) is a common cancer for women around the world, and early detection of BC can greatly improve prognosis and survival chances by promoting clinical treatment to patients early. So it’s amazing to be able to possibly help save lives just by using data, python, and machine learning!

If you prefer not to read this article and would like a video representation of it, you can check out the YouTube Video below. It goes through everything in this article with a little more detail, and will help make it easy for you to start programming your own Machine Learning model even if you don’t have the programming language Python installed on your computer. Or you can use both as supplementary materials for learning about Machine Learning !

Start Programming:

The first thing that I like to do before writing a single line of code is to put in a description in comments of what the code does. This way I can look back on my code and know exactly what it does.

#Description: This program detects breast cancer, based off of data. 

Now import the packages/libraries to make it easier to write the program.

#import libraries 
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

Next I will load the data, and print the first 7 rows of data.

NOTE: Each row of data represents a patient that may or may not have cancer.

#Load the data 
#from google.colab import files # Use to load data on Google Colab #uploaded = files.upload() # Use to load data on Google Colab df = pd.read_csv('data.csv')
df.head(7)
A sample of the first 7 rows of data