Machine learning / explainability

Educational / read-only showcase

Explainable Cancer Diagnosis

A model can be right. How much can we honestly explain about why?

An educational study of model behavior on the Breast Cancer Wisconsin dataset, with bounded explanations and explicit limits.

Explainable Cancer Diagnosis overview with educational-use disclaimer
Primary evidenceThe overview keeps the educational-use boundary next to the model result.

Machine learning / explainability

This was never meant to be a diagnostic tool

I wanted to make the model inputs, split, artifacts, and feature explanations inspectable without accidentally presenting the project as something for real patients.

What I tried

  • Lock the dataset fingerprint, label contract, and 398 / 85 / 86 split.
  • Select a candidate on validation data and keep the governed test set frozen for regression.
  • Check model, metric, feature-order, and SHAP checksums before the API uses an artifact.

The rough shape of it

  1. 1

    Dataset rows → validation split → select Logistic Regression

  2. 2

    Frozen artifact → FastAPI prediction

  3. 3

    Model score + feature contribution → read-only React showcase

The result that needed a warning label

The 86-row test result is very strong and contains one error. That makes the caveat more important: a small clean dataset is not evidence of safety or clinical utility.

Explainable Cancer Diagnosis overview with educational-use disclaimer
The overview keeps the educational-use boundary next to the model result.

What came out of it

The dataset has 569 rows and 30 features. On the governed 86-row test, the report records 0.9844 balanced accuracy, 0.9841 malignant F1, 0.9954 ROC-AUC, and 0.9938 PR-AUC.

What the single test error tells us

On governed-test row 73, the true label is malignant but the model predicted benign (malignant-class score 0.1313): the only false negative in the 86-row test.

  • Aggregate scores can hide an important failure mode.
  • SHAP describes the contribution the model used, not biological causality.
  • One clean test set cannot establish clinical safety.
Feature contribution explanation for the educational model
The explanation shows how the model used a measurement; it is not a biological explanation.

What's still missing

  • The dataset is Breast Cancer Wisconsin (Diagnostic), not a symptom form or current patient record.
  • The malignant-class score is uncalibrated. It is not risk or a probability of cancer.
  • The public showcase is read-only, and this project is not diagnosis, screening, treatment, or clinical decision support.

What I'd change today

  • Put the score and explainability limits beside the first prediction view.
  • Keep regression-artifact language separate from benchmark language in every report.
  • Add sensitivity analysis for correlated features before describing SHAP as a reason.

Source and demo

The repository has the complete setup, tests, and implementation details.

See the code on GitHubOpen the read-only showcase