Skip to content

About

Hybrid CNN (MobileNetV2 + VGG16) + Random Forest for dermoscopic skin lesion classification — PH2 dataset

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

🔬 DermaAI — Hybrid CNN + Random Forest for Skin Lesion Classification (PH2)

Dermoscopic image classification pipeline combining frozen pretrained CNN feature extractors (MobileNetV2 + VGG16) with a Random Forest classifier, evaluated on the PH2 dataset (200 dermoscopic images, 3 classes: melanoma, common nevi, atypical nevi).

⚠️ Clinical disclaimer: this is a research/educational project. It is not a diagnostic tool and must not be used for clinical decision-making. In a real screening context, recall on the melanoma class (minimizing false negatives) matters more than overall accuracy.

🧠 Method

  1. Data: PH2 dataset (400 images after preprocessing, 3 imbalanced classes: melanoma 224, common nevi 100, atypical nevi 76).
  2. Split: stratified 65% train / 15% validation / 20% test (260 / 60 / 80 images).
  3. Augmentation (train set only): rotation ±25°, shift ±20%, shear, zoom, horizontal/vertical flip, brightness ±20% → 1,820 training images.
  4. Feature extraction: two frozen ImageNet-pretrained CNNs used as fixed feature extractors with global average pooling — MobileNetV2 (1,280-d) + VGG16 (512-d) → concatenated into a 1,792-d feature vector per image.
  5. Class balancing: SMOTE applied on the extracted features to balance the three classes (→ 1,015 samples per class).
  6. Classifier: Random Forest, hyperparameters tuned via RandomizedSearchCV (30 combinations × 5-fold stratified CV, optimizing macro-F1).
  7. Evaluation: classification report + confusion matrix on validation and held-out test sets.

📊 Results

Split Accuracy Macro F1 (best CV)
Validation 83.3% 0.976 (CV)
Test 87.5% —

Best Random Forest parameters: n_estimators=300, max_depth=None, min_samples_split=2, min_samples_leaf=1, class_weight=None, bootstrap=False

Test set — per-class performance:

Class Precision Recall F1-score
Atypical nevi 1.00 0.67 0.80
Common nevi 0.89 0.85 0.87
Melanoma 0.84 0.96 0.90

High melanoma recall (0.96) on the test set is the most clinically relevant result here: the model misses very few melanoma cases, at the cost of some false positives (lower precision), which is the safer trade-off for a screening-oriented use case.

📁 Repository structure

dermaai-ph2/
├── DermaAI_PH2.ipynb     # Full pipeline: data → features → SMOTE → RF → evaluation
├── requirements.txt
├── CITATION.cff / CITATION.md
└── LICENSE               # MIT

🚀 Running the notebook

The notebook is designed for Google Colab with a free T4 GPU:

  1. Open DermaAI_PH2.ipynb in Colab.
  2. Runtime → Change runtime type → T4 GPU.
  3. Run all cells — the PH2 dataset is fetched automatically via kagglehub (no manual download or Kaggle API token needed).
  4. Outputs (trained model, label encoder, confusion matrices, sample images) are saved to /content/outputs/.

Locally:

pip install -r requirements.txt
jupyter notebook DermaAI_PH2.ipynb

📦 Dataset

PH2 Dataset — 200 dermoscopic images of melanocytic lesions, acquired at the Dermatology Service of Hospital Pedro Hispano (Portugal), with manual segmentation and diagnosis by expert dermatologists.

✍️ Citation

See CITATION.cff / CITATION.md.

📄 License

MIT — see LICENSE.

About

Hybrid CNN (MobileNetV2 + VGG16) + Random Forest for dermoscopic skin lesion classification — PH2 dataset

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages