Diabetes Prediction Using Machine Learning

Introduction

For this project, I created a machine learning model to forecast the probability of diabetes in patients using the Healthcare Diabetes Dataset sourced from Kaggle. The dataset contained variables such as Pregnancy, Glucose, Blood Pressure, Skin Thickness, Insulin, BMI, Diabetes Pedigree Function, Age, and Outcome. My motivation behind this project stems from my deep interest in healthcare, my drive to address urgent problems, and the expertise I have gained through my experience as a data scientist in the healthcare industry.

Data Preprocessing

Handling Missing Values

During data preprocessing, I discovered that specific attributes, namely Glucose, blood pressure, skin thickness, Insulin, and BMI, had recorded minimum values of zero. Using my expertise in the field, I concluded that these zero values were not plausible and suggested that they represented missing data. Consequently, I substituted these mislaiding values (with a minimum of 0) with the average of their corresponding columns. By employing this approach, the dataset was enhanced in terms of accuracy and ability to reflect real-world situations accurately.

Standardizing Features

I classified the age feature into distinct age brackets to enhance its significance for the model. Implementing this binning approach significantly enhanced the model’s comprehension and classification of the age data. In addition, I applied a process of standardization to all the features, ensuring that they were all measured on the same scale. It is crucial to achieve optimal performance in numerous machine learning algorithms.

Exploratory Data Analysis (EDA)

The exploratory data analysis (EDA) indicated that the dataset contained no missing values. However, unrealistic zero values in multiple features required implementing the imputation above process. Once the missing values were filled in and the features were standardized, the data was prepared for model construction.

Model Building

Logistic Regression

At first, I constructed a logistic regression model to predict the probability of developing diabetes. The logistic regression model attained a precision rate of 75%. Although the initial model was satisfactory, I aimed to enhance its performance even more.

Random Forest Classifier

To improve the model’s accuracy, I utilized the Random Forest Classifier, an ensemble learning technique renowned for its resilience and exceptional precision. The Random Forest Classifier surpassed the logistic regression model, attaining a 98% accuracy rate. The notable enhancement demonstrated the model’s unique ability to differentiate between patients with and without diabetes.

Model Evaluation

The ultimate Random Forest Classifier exhibited a significant degree of accuracy, indicating its reliability as a model for diabetes prediction. The model’s performance metrics demonstrate its ability to efficiently aid healthcare professionals in identifying patients exposed to diabetes, enabling prompt intervention and treatment.

Deployment

I utilized Streamlit, a Python framework for constructing web applications, to deploy the diabetes prediction model, granting users access to it. Below is a comprehensive and sequential guide outlining the deployment process:

  • pip install streamlit
  • streamlit run diabetes_app.py
  • pip freeze > requirements.txt
  • Create a profile and deploy

GitHub: https://github.com/JonathanPollyn/PredictDiabeticML/tree/main

Streamlit App: https://jpdiabeticprediction.streamlit.app/

Conclusion

This project emphasizes the significance of accurate data preprocessing and the potential of machine learning in healthcare applications. Through effective handling of missing values and careful selection of a robust machine learning model, I have successfully developed a highly accurate diabetes prediction model. This project demonstrates the crucial significance of data science in healthcare and its capacity to enhance patient outcomes by facilitating early diagnosis and intervention.

Future Work

While the current model demonstrates high accuracy, future work could involve:

  • Incorporating more features: Additional relevant features could enhance the model’s performance further.
  • External validation: Validating the model on external datasets to ensure its generalizability and robustness.
  • Model interpretability: Implementing techniques to make the model’s predictions more interpretable for healthcare professionals.

By continuing to refine and validate the model, I can ensure its reliability and effectiveness in real-world clinical settings.