Skin Lesion Classification
Seven-class dermatoscopic lesion classification on HAM10000 (~10k images) with ResNet-18 transfer learning and class-weighted loss to counter severe class imbalance.
- PyTorch
- ResNet-18
- HAM10000
- torchvision
- scikit-learn

Seven-class classification of dermatoscopic images on the HAM10000 dataset (approximately 10,000 images), using ResNet-18 transfer learning.
Results
| Metric | Value |
|---|---|
| Test accuracy | 78% |
| Classes | 7 |
| Dataset size | ~10,000 images |
The imbalance problem
HAM10000 is severely imbalanced. Melanocytic nevi dominate the dataset, while several clinically important classes have only a few hundred examples. A model trained with plain cross-entropy learns the obvious shortcut: predict the majority class and collect a high accuracy score while being useless on exactly the cases that matter.
The fix used here was a class-weighted loss, weighting each class inversely to its frequency so that errors on rare classes carry proportionally more gradient. Evaluation was correspondingly done per class rather than in aggregate, using a confusion matrix and per-class recall, not a single accuracy number.
Approach
ResNet-18 pretrained on ImageNet, with the final fully-connected layer replaced for seven outputs and the whole network fine-tuned at a low learning rate. Images were resized and normalised to the ImageNet statistics the pretrained weights expect, with flips and mild colour jitter for augmentation. Splits were made so that no patient's lesion appears in both train and test, which otherwise leaks and inflates the reported score.