Skip to content

devfaizzz/anemia-detection-using-machine-learning

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

3 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš‘ Anemia Detection Using Machine Learning ๐Ÿš‘

An intelligent system for predicting anemia using Random Forest Classification

Python Flask License: MIT


Overview

This project implements a Random Forest Classifier to predict whether an individual is anemic or non-anemic based on their blood-related attributes. The project includes:

  • A Flask-based web application to interact with the model
  • Pre-trained model for predictions
  • A detailed implementation of training, class balancing, and feature importance analysis
  • NEW FEATURE: Upload a blood report image to predict anemia using Google Gemini 2.0 Flash for text extraction

Features

  1. Random Forest Classifier for high accuracy predictions
  2. SMOTE (Synthetic Minority Oversampling Technique) for handling class imbalance
  3. Feature Importance Analysis to identify the most significant contributors to predictions
  4. Simple frontend interface for user input
  5. NEW: Image-Based Prediction โ€“ Upload a blood test report image to automatically extract relevant values and get predictions

๐Ÿ“Š Performance Evaluation

Model Comparison Analysis

Algorithm Accuracy AUC
Random Forest 99% 99%
Logistic Regression 98% 98%
SVM 90% 90%
KNN 87% 87%

Random Forest Classifier demonstrates superior performance across both metrics.

๐Ÿฐ System Architecture

System Architecture

The system follows a structured pipeline from dataset handling to model predictions.

๐Ÿ“Š Dataset Attributes

  • ๐Ÿ’‰ Hemoglobin Levels
  • ๐Ÿ”ฌ Mean Corpuscular Volume (MCV)
  • ๐Ÿงช Mean Corpuscular Hemoglobin (MCH)
  • ๐Ÿ“ˆ Mean Corpuscular Hemoglobin Concentration (MCHC)
  • ๐Ÿ‘ค Gender

โš–๏ธ Class Balance Management

Balanced Dataset

Achieved perfect balance: 801 samples each for anemic and non-anemic classes using SMOTE

๐Ÿ” Feature Importance Analysis

Feature Importance

Key Contributors:

  • ๐ŸŸฅ Hemoglobin: 87.0% contribution
  • ๐Ÿ‘ฅ Gender: 9.1% contribution
  • ๐Ÿงฌ MCH: 2.7% contribution
  • ๐Ÿ’‰ Others: 1.2% contribution

Flask Web Application

๐Ÿ› ๏ธ Application Structure

Directory structure:
โ””โ”€โ”€ yogeshwaran10-anemia_detection/
    โ”œโ”€โ”€ README.md
    โ”œโ”€โ”€ Procfile
    โ”œโ”€โ”€ app.py
    โ”œโ”€โ”€ process_image.py
    โ”œโ”€โ”€ requirements.txt
    โ”œโ”€โ”€ runtime.txt
    โ”œโ”€โ”€ utils.py
    โ”œโ”€โ”€ images/
    โ”œโ”€โ”€ model/
    โ”‚   โ””โ”€โ”€ random_forest_classifier.pkl
    โ”œโ”€โ”€ static/
    โ”‚   โ””โ”€โ”€ style.css
    โ””โ”€โ”€ templates/
        โ””โ”€โ”€ index.html

๐Ÿ’ป Installation & Usage

1๏ธโƒฃ Clone the Repository

git clone <repository_url>
cd anemia-detection-using-machine-learning

2๏ธโƒฃ Install Dependencies

pip install -r requirements.txt

3๏ธโƒฃ Run the Application

python app.py

Then open the app in your browser at http://127.0.0.1:5000/

๐Ÿ“ˆ Results

  • โœ… High Accuracy: Achieved through class balancing and Random Forest optimization
  • ๐ŸŽฏ Precise Predictions: Driven by significant features like hemoglobin levels
  • ๐Ÿ“ธ New Image Upload Feature: Extracts blood test attributes automatically for prediction

๐Ÿ”ฎ Future Scope

  • ๐Ÿ“Š Expand dataset to include more diverse features
  • ๐Ÿš€ Implement advanced models like XGBoost or LightGBM
  • โš–๏ธ Address Feature scaling โš™๏ธ importance to other features

๐Ÿ“ธ Screenshots

1. System Architecture

System Architecture

2. Balanced Dataset After SMOTE

Balanced Dataset

3. Feature Importance Analysis

Feature Importance


Outcome Variable Explanation:

The outcome variable in the dataset indicates the final diagnosis or classification for each patient. The outcome is binary, with two possible values:

  • Not Anemic: The patient is not anemic, based on clinical criteria and test results.
  • Anemic: The patient is anemic, suggesting a deficiency of red blood cells or hemoglobin in the blood.

Contributing

Your contributions are welcome! Feel free to:

  • ๐Ÿ› Report bugs
  • ๐Ÿ’ก Suggest features
  • ๐Ÿ”ง Submit pull requests

๐Ÿ License

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

About

anemia sense: leveraging machine learning for precise anemia

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published