Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Melanoma Detection — Deep Learning & Ensemble Pipeline

## Results Snapshot
- Recall (malignant): ~0.90
- ROC-AUC: ~0.85
- Approach: CNN + Gradient Boosting + Stacking

Overview

This project builds an end-to-end machine learning pipeline for melanoma detection from dermatoscopic images. It combines deep learning, classical models, and ensemble techniques to improve classification performance.

The focus is not just accuracy, but clinical relevance:

  • Maximize detection of malignant cases (high recall)
  • Minimize false negatives
  • Understand model behavior through visual analysis

This system is designed as a screening tool, not a diagnostic solution.


Problem Framing

Melanoma is a high-risk skin cancer where early detection is critical.

In this context:

  • False negatives (missed melanoma) are far more costly than false positives
  • The model is optimized to prioritize sensitivity (recall) over precision

Dataset

Data is structured as:


melanoma_cancer_dataset/
├── train/
│   ├── benign/
│   └── malignant/
├── test/
│   ├── benign/
│   └── malignant/

Distribution

  • Train: 5000 benign, 4605 malignant
  • Test: 500 benign, 500 malignant

The dataset is relatively balanced, enabling stable evaluation of recall-focused models.


Methodology

Pipeline Design

The system is built in multiple layers:

  1. Deep Learning Model (CNN)

    • Learns visual features from images
    • Outputs probability scores and embeddings
  2. Classical Model (Gradient Boosting)

    • Trained on CNN embeddings
    • Captures additional non-linear patterns
  3. Ensemble Layer

    • Combines predictions from multiple models
  4. Meta-Classifier (Stacking)

    • Final decision layer
    • Includes probability calibration
    • Optimized threshold selection

Key Techniques

  • Image preprocessing and resizing
  • Class weighting for imbalance handling
  • Precision-Recall optimization
  • Threshold tuning (target recall ≥ 0.90)
  • Probability calibration for stable predictions

Tools and Technologies

Python TensorFlow Keras Scikit-learn Pandas NumPy Matplotlib Seaborn Joblib Pillow


Results and Performance

Final Model Performance

Class Precision Recall F1 Score
Benign ~0.96 ~0.61 ~0.75
Malignant ~0.36 ~0.90 ~0.52
  • Overall Accuracy: ~0.67
  • ROC-AUC: ~0.85

Interpretation

  • The model detects most malignant cases (high recall ~0.90)
  • Precision is lower, meaning more false positives
  • This trade-off is intentional and appropriate for screening systems

Visual Analysis

All graphs are stored in Graphs/.


1) Class Distribution

Class Distribution

What it shows:
Train and test distribution of benign vs malignant samples.

Interpretation:
Confirms near-balanced dataset, reducing bias toward one class.


2) Sample Images (Benign vs Malignant)

Examples

What it shows:
Representative examples from both classes.

Interpretation:
Highlights visual variability and classification difficulty.


3) False Positive Examples

False Positives

What it shows:
Benign images predicted as malignant.

Interpretation:
Acceptable errors in a recall-focused system; useful for understanding model confusion.


4) Precision-Recall Curve — Deep Learning Model

PR Deep

What it shows:
Baseline CNN performance.

Interpretation:
Establishes the initial precision-recall trade-off.


5) Precision-Recall Curve — Calibrated Ensemble

PR Ensemble

What it shows:
Performance after combining models and calibration.

Interpretation:
Improved stability and better trade-off than single models.


6) Precision-Recall Curve — Final Meta-Classifier

PR Final

What it shows:
Final optimized model performance.

Interpretation:
Achieves strong recall while maintaining acceptable precision.


7) Model Performance Comparison (Baseline)

Comparison Base

What it shows:
Initial comparison across models.

Interpretation:
Shows limitations of standalone approaches.


8) Updated Ensemble Comparison

Comparison Updated

What it shows:
Performance improvements after ensemble tuning.

Interpretation:
Demonstrates gains from combining models.


9) Final Meta-Classifier Comparison

Comparison Final

What it shows:
Final model vs previous approaches.

Interpretation:
Confirms stacking + calibration as the best-performing approach.


10) F1-Optimized Model

F1 Optimized

What it shows:
Model tuned for balanced precision and recall.

Interpretation:
Useful when reducing false positives is important.


11) Recall-Optimized Model

Recall Optimized

What it shows:
Model tuned for maximum malignant detection.

Interpretation:
Best configuration for screening scenarios.


Key Takeaways

  • High recall is achievable through ensemble methods and threshold tuning
  • Model stacking significantly improves performance over individual models
  • Increasing recall leads to more false positives (expected trade-off)
  • The system is suitable for pre-screening, not final diagnosis

Limitations

  • No external dataset validation (risk of overfitting)
  • Limited interpretability (no Grad-CAM or explainability yet)
  • Performance depends on image quality and dataset diversity

How to Run

  1. Install dependencies:
pip install -r requirements.txt
  1. Run the full pipeline:
  • Open melanoma_detection_v1.ipynb
  • Execute all cells sequentially

Disclaimer

This project is intended for research and educational purposes only. It should not be used for clinical diagnosis without validation by medical professionals.

About

End-to-end melanoma detection pipeline using CNNs, ensemble learning, and threshold optimization to prioritize high recall in medical screening.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages