This project aims to build a machine learning model to predict the likelihood of diabetes based on various health-related indicators. The dataset used in this project comes from the 2023 Behavioral Risk Factor Surveillance System (BRFSS) survey, which captures data on a wide range of health behaviors and conditions across various demographics. The target variable classifies individuals into two categories: diabetic and non-diabetic (including pre-diabetes).
The project follows a complete pipeline that involves:
- Data preprocessing.
- Addressing class imbalance.
- Training a robust Artificial Neural Network (ANN) for prediction.
- Dataset: BRFSS 2023 Annual Data
- Referred Code: Diabetes Health Indicators Notebook
- Health Indicator References: CDC - PCD Article (2019)
The dataset includes various health indicators and a binary target variable (Diabetes_binary) representing the presence or absence of diabetes.
-
Dataset Format:
- The 2023 BRFSS Data was initially available in XPT (SAS EXPORT) format. We used the Pandas
read_sasmethod to load the dataset into a Pandas DataFrame and subsequently saved it as a CSV file for later use.
- The 2023 BRFSS Data was initially available in XPT (SAS EXPORT) format. We used the Pandas
-
Feature and Target Separation:
- Features (
X) were separated from the target variable (y). - The target variable is the
Diabetes_binarycolumn.
- Features (
-
One-Hot Encoding:
- Categorical columns were identified and one-hot encoded to ensure compatibility with machine learning models.
-
Train-Test Split:
- The dataset was split into training (70%) and testing (30%) subsets using a stratified approach to maintain class distribution.
The dataset was balanced using the SMOTETomek technique:
- SMOTE (Synthetic Minority Oversampling Technique): Synthetic examples of the minority class were generated.
- Tomek Links: Instances causing class overlap were removed to enhance class separation. This resulted in a balanced training dataset, addressing the class imbalance problem that is common in healthcare datasets.
All features were standardized using StandardScaler to normalize feature values. This step ensures that all features contribute equally to the model and aids in faster and more stable training.
We implemented a fully connected artificial neural network using TensorFlow and Keras. The architecture includes:
- Input Layer: Matches the number of features in the dataset.
- Hidden Layers:
- Three dense layers with ReLU activation for non-linear transformations.
- Batch normalization layers for stabilizing and accelerating training.
- Dropout layers (50% rate) to prevent overfitting.
- Output Layer: A single neuron with a sigmoid activation function for binary classification.
The model was compiled with:
- Loss Function:
binary_crossentropyfor binary classification tasks. - Optimizer:
Adamwith a learning rate of 0.001 for efficient gradient descent. - Metrics: Accuracy was used as the primary performance metric.
Training Details:
- The model was trained for 20 epochs with a batch size of 32.
- Validation was performed on the test dataset to monitor generalization.
The model's performance was evaluated using:
- Accuracy: Measures overall predictive correctness.
- Classification Report: Includes precision, recall, F1-score, and support for both classes.
The model demonstrated high accuracy and robust performance on the test set, making it a reliable tool for diabetes prediction based on health indicators.
- Preprocessing: Feature separation, one-hot encoding, SMOTETomek balancing, and feature scaling.
- Model: Fully connected neural network with dropout, batch normalization, and ReLU activations.
- Evaluation: Classification metrics and accuracy.
To reproduce this project:
- Install dependencies:
pip install pandas numpy scikit-learn imbalanced-learn tensorflow
- Place the dataset in the specified path:
Data/diabetes_binary_5050split_health_indicators_BRFSS2023.csv. - Run the script.
This project demonstrates how to process and model health-related data to predict diabetes using machine learning techniques. The dataset was preprocessed to handle missing values, reclassify variables, and balance the target classes. A neural network was trained, and its performance evaluated to predict diabetes effectively.