Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🩺 Diabetes Prediction using K-Nearest Neighbors (KNN)

📌 Project Overview

This project aims to predict whether a patient has diabetes using the Pima Indians Diabetes Dataset and the K-Nearest Neighbors (KNN) classification algorithm.

The project covers the complete machine learning workflow, from data preprocessing to model evaluation.


📂 Dataset

  • Dataset: Pima Indians Diabetes Dataset
  • Source: Kaggle / UCI Machine Learning Repository

Features

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

Target

  • 0: Non-Diabetic
  • 1: Diabetic

🛠 Technologies Used

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

📋 Machine Learning Workflow

  1. Data Loading
  2. Data Exploration
  3. Data Cleaning
  4. Train/Test Split
  5. Feature Scaling using StandardScaler
  6. KNN Model Training
  7. Hyperparameter Tuning (Best K Selection)
  8. Model Evaluation
    • Accuracy
    • Confusion Matrix
    • Classification Report

📊 Results

Best K value:

K = 17

Model Performance:

Metric Score
Accuracy 77%
Precision (Diabetic) 72%
Recall (Diabetic) 56%
F1-Score (Diabetic) 63%

📚 What I Learned

During this project I learned how to:

  • Build a classification model using KNN.
  • Split data into training and testing sets.
  • Standardize numerical features.
  • Tune hyperparameters.
  • Evaluate a classification model using:
    • Accuracy
    • Precision
    • Recall
    • F1-score
    • Confusion Matrix

🚀 Future Improvements

  • Try Decision Tree Classifier.
  • Compare multiple classification algorithms.
  • Improve recall for diabetic patients.
  • Deploy the model using Streamlit.

👨‍💻 Author

Taha Lazar

About

Diabetes prediction using the K-Nearest Neighbors (KNN) algorithm with Python and Scikit-learn.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages