Skip to content

Multilayer perceptron

Benign vs malignant tumour classifier. Layers, losses and optimisers written in NumPy behind a Keras-like API.

ROLE
Solo · École 42 · AI projects
STACK
Python · NumPy · pandas
RESULT
97.4 % validation accuracy on one 80/20 split, also used for early stopping.
READING TIME
1 min read
1

Data

Wisconsin Breast Cancer (Diagnostic), UCI: 569 tumours described by measurements of cell nuclei, labelled benign or malignant.

2

What I built

Solo

  1. A Keras-like API: a CustomSequential model stacking Dense layers.
  2. Forward pass and backpropagation, with binary cross-entropy, categorical cross-entropy and MSE losses.
  3. SGD and Adam optimisers, and early stopping on validation loss.
  4. A Colab notebook that trains and evaluates the model end to end.
3

Key choices

Mirror the Keras API
I followed the structure of the official Keras documentation, with layers, losses and optimisers as separate classes behind one model object. It kept the code modular instead of a growing pile of functions.
4

Results

90 %100 %Adam, 24-24 · cell 2797.4 %Early stop · cell 2296.5 %Run · cell 2994.7 %
Wisconsin Breast Cancer (Diagnostic) dataset, 569 samples. One 80/20 split (--valid_ratio 0.2, seed 42); the validation split also drives early stopping; no separate test set. Source: MLP_Presentation.ipynb outputs.

97.4 % validation accuracy on one 80/20 split, also used for early stopping.

5

Limits

  • The validation split also drives early stopping, and there is no separate test set, so these scores are optimistic.
  • The logs show overfitting: training accuracy reaches 1.0 while validation loss rises from 0.20 to 0.73.
  • One split of 569 samples: a different seed could move the score by a few points. Cross-validation would give a range.

Questions about this project? → Email me