ML · FastAPI · Docker · Google Cloud Run

Breast Cancer
Classifier.

Logistic Regression and Random Forest models trained on the Wisconsin Breast Cancer dataset, served via a FastAPI REST endpoint, containerized with Docker, and deployed to Google Cloud Run — a full production ML pipeline.

Production Pipeline Cloud Run
1
Wisconsin Dataset 569 samples · 30 features · binary labels
2
Train Models Logistic Regression + Random Forest · scikit-learn
3
FastAPI Service REST endpoint · /predict · JSON in, prediction out
4
Docker Container Portable · reproducible · production-ready image
5
Google Cloud Run Serverless · auto-scaling · public HTTPS endpoint

Model performance.

97.4%
Logistic Regression accuracy
// Wisconsin test set
96.5%
Random Forest accuracy
// Wisconsin test set
30
Input features
// cell nucleus measurements
569
Training samples
// malignant + benign
Logistic Regression

Simple, interpretable, fast

A linear model that learns decision boundaries in feature space. Strong baseline for binary medical classification — weights are directly interpretable as feature importance.

  • 97.4% accuracy on Wisconsin test set
  • Fast inference — suitable for real-time API responses
  • Coefficients give direct clinical feature insight
  • Minimal risk of overfitting on small datasets
Random Forest

Ensemble, robust, feature-aware

An ensemble of decision trees that votes on the final prediction. Captures non-linear feature interactions and provides built-in feature importance ranking.

  • 96.5% accuracy — strong generalisation from ensembling
  • Feature importance ranking across all 30 features
  • Robust to outliers and noisy measurements
  • No feature scaling required

Full pipeline design.

Wisconsin Breast Cancer Dataset 569 samples · 30 numeric features · labels: Malignant / Benign ────────────────────────────────────────────────────────────── Preprocessing ├── Train / test split (80 / 20) ├── StandardScaler → zero mean, unit variance └── Applied to both LR and RF pipelines Model 1 — Logistic Regression scikit-learn ├── Solver: lbfgs Max iter: 10,000 ├── Regularization: L2 (C = 1.0) └── Output: P(malignant) + binary label Model 2 — Random Forest scikit-learn ├── n_estimators: 100 max_features: sqrt ├── Bootstrap sampling: True └── Output: majority vote + class probabilities ────────────────────────────────────────────────────────────── FastAPI Service ├── POST /predict │ body: { "features": [f1, f2, ... f30], "model": "lr" | "rf" } │ resp: { "prediction": "malignant" | "benign", "confidence": 0.97 } ├── GET /health └── GET /docs (auto Swagger UI) Docker ├── Base image: python:3.11-slim ├── Copies model artefacts + app └── EXPOSE 8080 → uvicorn main:app Google Cloud Run ├── Serverless container runtime ├── Auto-scales to zero when idle └── Public HTTPS endpoint → zero infrastructure management

From laptop to cloud.

🧪
Training

scikit-learn

Models trained locally, serialized with joblib. Both LR and RF packaged as model artefacts alongside the API.

joblibpickle
API

FastAPI

Async REST service with automatic Swagger UI. Input validation via Pydantic. Returns prediction and confidence score.

PydanticUvicornSwagger
🐳
Container

Docker

Reproducible build. All dependencies, model artefacts, and the app bundled into a single portable image.

python:3.11-slimEXPOSE 8080
☁️
Cloud

Google Cloud Run

Serverless container hosting. Scales to zero when idle, auto-scales under load. Public HTTPS endpoint, no server management.

ServerlessAuto-scalingHTTPS
~ docker build -t breast-cancer-classifier .
Successfully built a3f92c1d8e04
~ docker run -p 8080:8080 breast-cancer-classifier
INFO: Uvicorn running on http://0.0.0.0:8080
~ gcloud run deploy --image breast-cancer-classifier --platform managed
Deploying container to Cloud Run service in region us-central1...
Service URL: https://breast-cancer-classifier-xxxx.run.app
~ curl -X POST /predict -d '{"features":[...], "model":"lr"}'
{
"prediction": "benign",
"confidence": 0.974,
"model": "logistic_regression"
}
~

Built with.

CategoryToolPurpose
DatasetWisconsin Breast Cancer UCI / sklearn569 samples, 30 features, binary classification
Modelsscikit-learn LR + RFLogistic Regression and Random Forest classifiers
APIFastAPI + PydanticREST endpoint with automatic validation and Swagger docs
ServerUvicornASGI server for FastAPI
ContainerDocker python:3.11-slimReproducible, portable deployment image
CloudGoogle Cloud Run serverlessZero-ops container hosting with auto-scaling
SerializationjoblibSave and load trained model artefacts