Skip to content

05Menna/CKD-Multi-Stage-Classification-using-Machine-Learning

Repository files navigation

🩺 Chronic Kidney Disease Multi-Stage Classification using Machine Learning

An end-to-end Machine Learning project for predicting the stage of Chronic Kidney Disease (CKD) using clinical and laboratory data.

Streamlit App: https://ckd-multi-stage-classification-using-machine-learning-dgahtk2y.streamlit.app

The project demonstrates the complete machine learning workflow, from data preprocessing and exploratory data analysis (EDA) to feature engineering, dimensionality reduction, model optimization, and evaluation using a robust Scikit-Learn pipeline.


📌 Project Overview

Chronic Kidney Disease (CKD) is a progressive medical condition that can lead to kidney failure if not detected early. Accurate stage classification enables timely intervention and improved patient outcomes.

The objective of this project is to classify patients into one of five CKD stages:

  • 🟢 Healthy Kidney
  • 🟡 Stage 2
  • 🟠 Stage 3
  • 🔴 Stage 4
  • ⚫ Kidney Failure (Stage 5)

using supervised machine learning techniques.


🎯 Objectives

  • Perform comprehensive data preprocessing.
  • Analyze feature distributions and correlations.
  • Reduce dimensionality while preserving useful information.
  • Select the most informative features.
  • Build an optimized machine learning pipeline.
  • Evaluate the model using multiple classification metrics.

📂 Dataset

The dataset contains clinical and laboratory measurements collected from CKD patients.

Features include:

  • Age
  • Blood Pressure
  • Albumin
  • Creatinine
  • Blood Urea
  • Hemoglobin
  • eGFR
  • Diabetes
  • Hypertension
  • Smoking Status
  • Family History
  • and additional laboratory measurements.

Target Variable

CKD Stage (5 Classes)


🔬 Project Workflow

1️⃣ Data Preprocessing

Performed comprehensive preprocessing including:

  • Data inspection
  • Missing value analysis
  • Duplicate detection
  • Outlier detection
  • Feature encoding
  • Feature scaling
  • Class distribution analysis

Numerical Features

  • RobustScaler

Categorical Features

  • Label Encoding

2️⃣ Exploratory Data Analysis (EDA)

Performed extensive EDA to better understand the dataset.

Analysis included:

  • Distribution analysis
  • Histograms
  • Boxplots
  • Correlation Heatmaps
  • Skewness Analysis
  • Kurtosis Analysis
  • Outlier Detection
  • Target Class Distribution

3️⃣ Feature Selection

Multiple feature selection techniques were applied.

Filter Methods

  • Variance Threshold
  • Correlation Analysis
  • Mutual Information
  • Chi-Square Test

Wrapper Method

  • Sequential Forward Selection

These methods helped identify the most informative features while reducing redundancy.


4️⃣ Dimensionality Reduction

Principal Component Analysis (PCA) was applied to reduce feature dimensionality while preserving 95% of the dataset variance.

Benefits:

  • Reduced computational cost
  • Lower overfitting risk
  • Faster model training
  • Better model generalization

5️⃣ Machine Learning Pipeline

A Scikit-Learn Pipeline was built consisting of:

Raw Dataset
      │
      ▼
Data Preprocessing
      │
      ▼
RobustScaler
      │
      ▼
PCA
      │
      ▼
Support Vector Machine (SVC)
      │
      ▼
Prediction

6️⃣ Hyperparameter Tuning

Model optimization was performed using:

  • GridSearchCV
  • 5-Fold Cross Validation

Best Parameters

Parameter Value
Kernel RBF
C 10
Gamma 0.01
PCA Components 10

📈 Model Performance

Final Results

Metric Score
Accuracy 96.08%
Macro Recall 96.69%

Additional evaluation metrics:

  • Precision
  • Recall
  • F1-Score
  • Classification Report
  • Confusion Matrix

🛠️ Technologies Used

Programming

  • Python

Data Analysis

  • Pandas
  • NumPy

Visualization

  • Matplotlib
  • Seaborn

Machine Learning

  • Scikit-Learn

Algorithms & Techniques

  • Support Vector Machine (SVC)
  • Principal Component Analysis (PCA)
  • GridSearchCV
  • Cross Validation
  • Sequential Feature Selection
  • Chi-Square Test
  • Variance Threshold
  • Mutual Information

💡 Skills Demonstrated

  • Data Cleaning
  • Exploratory Data Analysis (EDA)
  • Statistical Analysis
  • Feature Engineering
  • Feature Selection
  • Dimensionality Reduction
  • Machine Learning
  • Multi-Class Classification
  • Hyperparameter Optimization
  • Model Evaluation
  • Pipeline Development

🚀 Key Achievements

✅ Built a complete end-to-end machine learning workflow.

✅ Applied multiple feature selection techniques.

✅ Reduced dimensionality using PCA.

✅ Optimized the model with GridSearchCV.

✅ Achieved 96.08% Accuracy.

✅ Achieved 96.69% Macro Recall across five CKD stages.


🔮 Future Improvements

  • Compare additional ensemble models (XGBoost, LightGBM, Random Forest).
  • Deploy the model using Streamlit.
  • Apply Explainable AI techniques (SHAP, LIME).
  • Address class imbalance using SMOTE.
  • Build a web application for real-time prediction.

Releases

Packages

Contributors

Languages