Skip to content

This project focuses on predicting Chronic Kidney Disease (CKD) using neural networks. It involves comprehensive data preprocessing, exploratory data analysis, and model interpretability to provide a robust classification solution based on health records.

Notifications You must be signed in to change notification settings

ryuzaki-ved/ckd_detection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

16 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🩺 Chronic Kidney Disease Prediction using Neural Networks

Python TensorFlow License: MIT

🎯 Overview

This project leverages the power of Neural Networks to predict Chronic Kidney Disease (CKD) based on a comprehensive set of health records. Utilizing the UCI Chronic Kidney Disease dataset, this solution provides a robust classification model, complete with detailed data preprocessing, exploratory data analysis, and model interpretability.

πŸ”¬ Medical AI at its finest - Helping healthcare professionals make informed decisions through machine learning

✨ Key Features

πŸ”§ Data Processing & Engineering

  • Smart Missing Value Handling: Robust imputation using mean/median for numerical and mode for categorical data
  • Data Cleaning: Automated detection and correction of inconsistent data entries
  • Feature Engineering: Label encoding, Min-Max scaling, and PCA dimensionality reduction
  • Class Balance: RandomOverSampler to handle imbalanced datasets

πŸ“Š Comprehensive Analysis

  • Exploratory Data Analysis: Interactive visualizations including pairplots, distribution plots, and boxplots
  • Outlier Detection: Advanced statistical methods to identify and handle outliers
  • Correlation Analysis: Heatmaps to understand feature relationships

🧠 Advanced Neural Network

  • Sequential Keras Model: Optimized architecture with Dense layers and Dropout
  • Hyperparameter Tuning: Fine-tuned for optimal performance
  • Early Stopping: Prevents overfitting during training

πŸ“ˆ Model Evaluation & Interpretability

  • Multi-metric Evaluation: Accuracy, F1-Score, AUC, Precision-Recall curves
  • Confusion Matrix: Detailed classification performance analysis
  • SHAP Integration: Explainable AI for transparent decision-making
  • Feature Importance: Understanding which health indicators matter most

πŸ“Š Dataset Information

Attribute Description Type
Dataset Source UCI ML Repository -
Instances 400 patients -
Features 24 health indicators Mixed
Target CKD vs Non-CKD Binary

πŸ₯ Health Indicators Include:

  • Age, Blood Pressure, Specific Gravity
  • Albumin, Sugar, Red Blood Cells
  • Hemoglobin, Packed Cell Volume
  • White Blood Cell Count, and more...

πŸš€ Quick Start

Prerequisites

Python 3.7+
pip (Python package manager)

Installation

# Clone the repository
git clone https://github.com/ryuzaki-ved/ckd_detection
cd chronic-kidney-disease-prediction

# Install required packages
pip install pandas numpy matplotlib seaborn scikit-learn imbalanced-learn tensorflow shap opencv-python

πŸƒβ€β™€οΈ Running the Model

# Run the main prediction script
python code1.py

# For step-by-step analysis
python converted_code.py

πŸ“ Project Structure

πŸ“¦ chronic-kidney-disease-prediction/
β”œβ”€β”€ πŸ“„ README.md                    # You are here!
β”œβ”€β”€ πŸ“„ LICENSE                      # MIT License
β”œβ”€β”€ 🐍 code1.py                     # Main neural network implementation
β”œβ”€β”€ 🐍 converted_code.py            # Step-by-step analysis
β”œβ”€β”€ 🐍 digital_tissue_mapping.py    # Additional tissue analysis
β”œβ”€β”€ πŸ“Š kidney_disease.csv           # Original dataset
β”œβ”€β”€ πŸ“Š Final_pre_processing_data.csv # Processed dataset
β”œβ”€β”€ πŸ€– kidney_disease_model.h5      # Trained model
β”œβ”€β”€ πŸ“ step_by_step.txt             # Detailed methodology
β”œβ”€β”€ πŸ”— helpful_links.txt            # Additional resources
└── πŸ“ output_images/               # Generated visualizations

πŸ“ˆ Model Performance

Our Neural Network achieves impressive results:

  • 🎯 High Accuracy: Optimized for medical diagnosis standards
  • βš–οΈ Balanced Performance: Handles both CKD and Non-CKD cases effectively
  • πŸ” Interpretable: SHAP values explain each prediction
  • πŸ“Š Comprehensive Metrics: F1-Score, Precision, Recall, AUC

Run the model to see exact performance metrics!

πŸ”¬ Advanced Features

πŸ§ͺ SHAP Explainability

# Generate SHAP explanations
explainer = shap.KernelExplainer(model.predict, x_train)
shap_values = explainer.shap_values(x_test[:100])
shap.summary_plot(shap_values, x_test[:100])

πŸ“Š Visualization Gallery

The project generates various visualizations:

  • πŸ“ˆ Training history plots
  • 🎯 ROC curves
  • πŸ“Š Precision-Recall curves
  • πŸ”₯ Confusion matrices
  • 🌟 SHAP feature importance plots

πŸ› οΈ Usage Examples

Basic Prediction

# Load and preprocess data
df = pd.read_csv("kidney_disease.csv")
# ... preprocessing steps ...

# Train model
model = create_neural_network()
history = model.fit(x_train, y_train, epochs=20)

# Make predictions
predictions = model.predict(x_test)

Model Interpretation

# Explain individual predictions
explain_prediction(model, explainer, sample_index=5)

🀝 Contributing

We welcome contributions! Here's how you can help:

  1. 🍴 Fork the repository
  2. 🌿 Create a feature branch (git checkout -b feature/AmazingFeature)
  3. πŸ’Ύ Commit your changes (git commit -m 'Add some AmazingFeature')
  4. πŸ“€ Push to the branch (git push origin feature/AmazingFeature)
  5. πŸ”„ Open a Pull Request

πŸ’‘ Ideas for Contributions

  • Additional ML algorithms comparison
  • Web interface for predictions
  • Mobile app integration
  • Enhanced visualizations
  • Performance optimizations

πŸ“š Documentation

  • πŸ“– Step-by-Step Guide: See step_by_step.txt for detailed methodology
  • πŸ”— Helpful Resources: Check helpful_links.txt for additional materials
  • πŸ“Š Research Papers: Explore the research_papers/ directory

πŸ† Acknowledgements

  • πŸŽ“ UCI Machine Learning Repository for the comprehensive dataset
  • 🧠 TensorFlow Team for the amazing deep learning framework
  • πŸ“Š SHAP Contributors for explainable AI capabilities
  • πŸ‘₯ Open Source Community for continuous inspiration

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ“ž Support & Contact

🌟 Star History

If this project helped you, please consider giving it a ⭐!


Made with ❀️ for better healthcare through AI

⬆ Back to Top

About

This project focuses on predicting Chronic Kidney Disease (CKD) using neural networks. It involves comprehensive data preprocessing, exploratory data analysis, and model interpretability to provide a robust classification solution based on health records.

Topics

Resources

Stars

Watchers

Forks