Skip to content

Multilayer perceptron

Classifies breast tumours as benign or malignant with a neural network written in NumPy: layers, losses and optimisers behind a Keras-like API.

TL;DR
  • 97.4 % val. accuracy
  • 569 samples

My partA Keras-like API: a CustomSequential model stacking Dense layers.

ROLE
Solo
CONTEXT
École 42 · AI projects
STATUS
Done
RESULT
96.5–97.4 % validation accuracy across three 80/20 runs (seed 42); the main run with early stopping on validation loss reached 96.5 %.
LAST UPDATED
26 Sep 2026
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, run A97.4 %Early stopping, main run96.5 %Adam, 24-24, run B94.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. Runs A and B share the architecture and optimiser; the gap between them is run-to-run variation. Notebook cells 27 (run A), 22 (main run) and 29 (run B).

96.5–97.4 % validation accuracy across three 80/20 runs (seed 42); the main run with early stopping on validation loss reached 96.5 %.

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 and training loss falls to ~0 while validation loss climbs to 0.66–0.73 by epoch 50.
  • 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