01The model
- Three convolutional blocks (Conv2d → ReLU → MaxPool), then two fully connected layers over two classes.
- Inputs resized to 224×224, with random horizontal flips and small rotations for light augmentation.
- Cross-entropy loss, Adam (lr 0.001), batch size 32, 5 epochs.
- Accuracy, precision, recall, F1 and a confusion matrix computed on the test split.
02The baseline
Logistic regression treats every pixel independently, so it can't learn shapes or textures. It's there to show how much the CNN gains from learning visual features directly, and the CNN beats it substantially.
03Results & the trade-off
The CNN's strength is recall. It misses very few pneumonia cases. The cost is a high false-positive rate: the model leans towards predicting pneumonia, which I put down to class imbalance in the dataset and the overfitting visible in the training vs validation curve.
In a clinical-support setting this profile is deliberate, because missing a pneumonia case costs more than a false alarm. It still isn't reliable enough for unaided clinical use.
04Limitations & next steps
- False positives are the main target for improvement.
- Overfitting: a small dataset and light augmentation leave a widening train/validation gap. Stronger augmentation or more data would help.
- The dataset's validation split has only a handful of images, so validation accuracy is noisy. The test split is the meaningful evaluation.
- Architecture: ResNet or DenseNet are the natural next step beyond this simplified CNN.