A PyTorch based implementation of a binary classification model for predicting the onset of diabetes. The model is trained on the Pima Indians Diabetes
dataset, which consists of medical records for Pima Indians, and is designed to predict whether a patient will develop diabetes within five years.
The notebook guides you through the following steps:
- Load Data
- Define the PyTorch Model
- Define Loss Function and Optimizers
- Run a Training Loop
- Evaluate the Model
- Make Predictions
Pima Indians Diabetes:
This dataset contains patient medical record data for Pima Indians and indicates whether they had an onset of diabetes within five years. The problem is framed as a binary classification problem where the onset of diabetes is represented as 1
and no onset as 0
.
The dataset has 9 columns:
-
Input Variables (X):
- Number of times pregnant
- Plasma glucose concentration at 2 hours in an oral glucose tolerance test
- Diastolic blood pressure (mm Hg)
- Triceps skin fold thickness (mm)
- 2-hour serum insulin (μIU/ml)
- Body mass index (weight in kg/(height in m)^2)
- Diabetes pedigree function
- Age (years)
-
Output Variable (y): 9. Class label (0 or 1)
The model is a simple neural network with the following architecture:
- The input layer expects 8 features.
- The first hidden layer has 200 neurons with a
ReLU
activation function. - The second hidden layer has 100 neurons with a
ReLU
activation function. - The output layer has 1 neuron with a
sigmoid
activation function.
- Clone this repository to your local machine:
git clone git@github.com:IsmaelMousa/diabetes-classification.git
- Navigate to the diabetes-classification directory:
cd diabetes-classification
- Setup virtual environment:
python3 -m venv .venv
- Activate the virtual environment:
source .venv/bin/activate
- Install the required dependencies:
pip install -r requirements.txt
- Run the Jupyter Notebook:
jupyter-notebook
The model's performance is evaluated by using the accuracy metric, and we got: 88.6%
The dataset used in this project is available on Kaggle: Pima Indians Diabetes.