Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🌲 Diabetes Prediction using Random Forest

📌 Project Overview

This project uses a Random Forest Classifier to predict whether a patient has diabetes based on medical diagnostic measurements from the Pima Indians Diabetes Dataset.

The project covers the complete machine learning workflow, including data preprocessing, hyperparameter tuning with GridSearchCV, model evaluation, and feature importance analysis.


📂 Dataset

  • Dataset: Pima Indians Diabetes Database
  • Target Variable: Outcome
    • 0: Non-Diabetic
    • 1: Diabetic

Features include:

  • Pregnancies
  • Glucose
  • BloodPressure
  • SkinThickness
  • Insulin
  • BMI
  • DiabetesPedigreeFunction
  • Age

🛠️ Technologies Used

  • Python
  • NumPy
  • Pandas
  • Matplotlib
  • Seaborn
  • Scikit-learn
  • Jupyter Notebook

📊 Project Workflow

  • Load the dataset
  • Exploratory Data Analysis (EDA)
  • Data cleaning
  • Train-Test Split
  • Train a Random Forest Classifier
  • Hyperparameter tuning using GridSearchCV
  • Model evaluation
  • Feature importance analysis

🔍 Hyperparameter Tuning

The Random Forest model was optimized using GridSearchCV with 5-fold cross-validation.

The following hyperparameters were tested:

  • n_estimators: 20, 50, 100
  • max_depth: 3, 5, 7, 9

Best parameters found:

  • n_estimators: 100
  • max_depth: 5

📈 Results

  • Accuracy: 74.0%
  • Confusion Matrix
  • Classification Report
  • Feature Importance Visualization

📊 Model Comparison

Model Accuracy
K-Nearest Neighbors 79.2%
Decision Tree 78.6%
Random Forest 74.0%

Although Random Forest is generally more powerful than a single Decision Tree, it did not achieve the highest accuracy on this dataset. This demonstrates that model performance depends on the dataset and that a more complex algorithm is not always the best choice.


🚀 Key Learning Outcomes

Through this project, I learned how to:

  • Train a Random Forest Classifier
  • Tune hyperparameters using GridSearchCV
  • Apply cross-validation
  • Evaluate a classification model
  • Interpret feature importance
  • Compare multiple machine learning models

📁 Project Structure

Project_03_Diabetes/
│
├── diabetes_random_forest.ipynb
├── diabetes.csv
├── README.md
├── requirements.txt
└── .gitignore

👨‍💻 Author

Taha Lazar

About

Diabetes prediction using a Random Forest Classifier with GridSearchCV hyperparameter tuning, feature importance analysis, and model evaluation using Python and Scikit-learn

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages