The short version: a blend of LightGBM on the metadata and a small CNN on the images reached a partial AUC of 0.169 out of 0.2 in cross-validation. The feature that helped most was comparing a lesion to the other lesions of the same patient.
The problem
The data is from the Kaggle competition ISIC 2024. It has 401,059 small crops of skin lesions, cut out of 3D total body photos, with a table of measurements for each one (size, color, shape, body location). Only 393 of them are malignant. That is about 1 in 1,000.
With so few positives, accuracy is useless: a model that says “benign” every time is 99.9% accurate. The competition uses the partial AUC above 80% true positive rate instead. It only scores the part of the ROC curve where the model already finds at least 80% of the cancers, and the maximum is 0.2.
The lesions come from 1,042 patients, and one patient has hundreds of them. So I split the 5 validation folds by patient. If lesions of the same patient end up in both training and validation, the score looks better than it really is.
I also had to drop some columns. A few exist only in the training data and are filled in after the biopsy, so they give away the answer.
What I built
I started with two simple benchmarks: one color feature on its own, and a logistic regression. Then I built two models and combined them.
- LightGBM on the metadata. My first run was worse than the benchmark (0.036). The model had memorized the few malignant lesions. Training on all malignant lesions but only 1% of the benign ones fixed it.
- Patient-normalized features. Dermatologists look for the “ugly duckling”, the mole that looks different from the others on the same person. I added features that compare each lesion to the patient’s own average. The hue version became the most important feature of the whole model.
- A CNN on the images. A pretrained ResNet18 on the 128-pixel crops, trained for 5 epochs on my laptop GPU. It is weaker than LightGBM on its own.
- The blend. The two models make different mistakes (rank correlation 0.46), so I averaged their ranks with 70% LightGBM and 30% CNN.
After that I ran everything again on SageMaker: training jobs for both models, a hyperparameter tuning job with 12 runs, and an endpoint that takes all lesions of one patient and returns them ranked. The tuning did not beat my defaults, so I kept them. The training jobs cost about $0.18.
Results
| Model | pAUC (mean ± std) |
|---|---|
| Benchmark: one color feature | 0.0809 ± 0.0247 |
| Benchmark: logistic regression | 0.1116 ± 0.0205 |
| LightGBM on the metadata | 0.1644 ± 0.0079 |
| CNN on the images | 0.1432 ± 0.0134 |
| Blend (70% LightGBM, 30% CNN) | 0.1691 ± 0.0067 |
The blend beats the logistic regression on all 5 folds. At the point where it finds 80% of the cancers, it wrongly flags about 5% of the benign lesions.
On Kaggle’s hidden test set the blend scored 0.1706 on the public part and 0.1590 on the private part (late submission).
The top of the leaderboard is very close together: a silver medal on the private part starts at about 0.1705. So my model is a good step above the benchmarks, but it is not close to the best solutions.
I also tried stacking, where the CNN score is a feature for LightGBM. It was slightly higher on average (0.1703) but less stable between folds, so I kept the simpler blend.
Later I added XGBoost, CatBoost, more features and more seeds. In cross-validation the gain was inside the noise (0.1705 against 0.1691). On Kaggle it moved to 0.1745 public and 0.1604 private. The three boosting libraries turned out to be nearly the same model on this data.
What the score hides
After the project was reviewed I went back and asked what the 0.169 doesn’t tell me. I used a bootstrap over patients to get an interval for every number.
| Question | Short answer |
|---|---|
| How noisy is the score? | About ±0.004 (one std). Blend over LightGBM is real, stacking over blend is not. |
| Cancer, or “looks suspicious”? | Against biopsied benign lesions the pAUC drops from 0.169 to 0.118. |
| A hospital it has never seen? | 0.164 to 0.150 for LightGBM, and the drop is real. |
| Ugly duckling and lesion count? | The gain only shows for patients with more than about 680 lesions. |
| Skin tone, age, sex? | No clear differences, but the groups are too small to be sure. |
| Cancer types? | The CNN adds about 8% everywhere. Melanoma is missed most often. |
The second row surprised me most. Every malignant lesion in the data was biopsied, but 95% of the benign ones never were, because nobody found them suspicious. The model ranks the biopsied benign lesions high too. So the headline score mostly measures how well it separates cancers from lesions nobody was worried about.
What I take from this: the score is correct, but it describes an easier job than it sounds like. The model is good at sorting out harmless lesions, at a hospital it knows, for patients with a full-body scan.
On the hard cases it is still far better than guessing (AUC 0.88), which is enough for triage. It can’t replace the decision to biopsy.
What I would change
- The CNN is the weak part. On SageMaker it scored 0.1315 with the same code, so it changes a lot from run to run. Averaging several seeds or adding older ISIC images would help.
- I compared many models on the same 5 folds. A group of patients kept out of all development would give a cleaner final number.
- The best Kaggle solutions used stronger image models. After trying more boosting models myself, I think that is where most of the gap is.
- Use the biopsied lesions as a second metric, and build a second model for the step from “suspicious” to “cancer”.
The report has the full details and the figures. The proposal is the plan I wrote before starting. The notebooks and scripts are on GitHub.