← Back to projects View source code

Breast Cancer Classification & Model Evaluation

Comparing supervised machine learning models for benign-versus-malignant classification using screening-derived tumor features.

This project evaluates multiple classification models on breast cancer screening data, with emphasis on malignant-case recall, model generalization, training behavior, and responsible interpretation of healthcare machine learning results.

Logistic Regression • Neural Networks • Random Forest • XGBoost • Model Evaluation

569 Screening records analyzed
30 Predictive tumor features
98.25% Best reported test accuracy
97.62% Best malignant-case recall

Project Overview

This project explores breast cancer classification as a healthcare machine learning case study. The goal is to compare how different supervised models classify benign and malignant records, while paying close attention to recall, generalization, and responsible interpretation.

Classification Modeled benign-versus-malignant outcomes using screening-derived tumor features.
Evaluation Compared accuracy, precision, recall, F1-score, confusion matrices, and validation behavior.
Responsible ML Framed results as model-evaluation evidence, not as a clinical diagnostic system.

Dataset and Preprocessing

The dataset contains 569 labeled records with 30 numeric screening-derived features after removing the ID column. The target variable is encoded into benign and malignant classes, and models are trained and evaluated using a stratified train-test split.

Class distribution of benign and malignant breast cancer records
Class distribution. The dataset contains more benign than malignant records, creating a moderate class imbalance. This makes malignant-class recall and F1-score important evaluation metrics.
Radius feature distribution by diagnosis
Feature separation. Radius-related measurements show visible differences between benign and malignant groups, supporting their predictive value in the classification workflow.

Preprocessing Note

The preprocessing workflow splits the data before scaling, then fits the StandardScaler only on the training set. The fitted scaler is used to transform both the training and test sets, avoiding preprocessing leakage and making model evaluation more reliable.

Modeling Approach

The project compares interpretable, tree-based, boosted, and neural network classifiers. This provides a broader view of model behavior than relying on a single accuracy score.

01

Manual Logistic Regression

Implemented a logistic regression workflow to understand the mechanics of binary classification, cost reduction, and gradient-based learning.

02

Tree and Ensemble Models

Compared decision tree, random forest, and XGBoost classifiers to evaluate nonlinear decision boundaries and ensemble performance.

03

Neural Network Classifier

Trained a neural network and monitored accuracy and loss curves to assess training stability and validation behavior.

01 Prepare features Remove ID, encode diagnosis labels, split the data, then scale numeric features using the training set.
02 Train models Fit logistic regression, tree-based models, boosted models, and neural networks.
03 Evaluate performance Compare accuracy, malignant recall, F1-score, confusion matrices, and validation curves.

Model Performance

Logistic Regression and the Neural Network produced the strongest holdout-test results, with matching accuracy and malignant-case recall. Because this is a healthcare classification task, malignant-case recall is especially important: missed malignant cases are more consequential than many ordinary classification errors.

Model Accuracy Malignant Recall Portfolio takeaway
Neural Network 98.25% 95.24% High-performing model with strong recall and the highest cross-validation validation accuracy.
Manual Logistic Regression 98.25% 95.24% Interpretable, stable baseline with top-tier overall accuracy and recall.
Random Forest 97.37% 92.86% Strong ensemble baseline with slightly lower malignant recall.
XGBoost 97.37% 92.86% Competitive boosted-tree model with strong but not best recall.
Decision Tree 95.61% 88.10% Useful comparison model, but weaker generalization and recall.
Logistic regression confusion matrix for breast cancer classification
Confusion matrix. Logistic regression achieved strong class separation, with very few classification errors on the test set.
Neural network training and validation accuracy and loss curves
Neural network training behavior. Accuracy improved quickly and loss decreased across training, while validation performance remained close to the training trend, suggesting stable learning behavior.

Generalization and Bias-Variance Analysis

Beyond test accuracy, the notebook compares model generalization behavior using validation accuracy, bias-variance patterns, and learning curves. This helps explain not only which model performed well, but also whether performance appears stable.

Bias-variance tradeoff comparison across breast cancer classification models
Bias-variance comparison. The analysis contrasts training and validation behavior to identify models that generalize better versus models that may overfit.

Interpretation

The strongest models combine high accuracy with stronger malignant-case recall and better validation behavior. The decision tree performs reasonably, but its weaker recall and larger train-validation gap make it less attractive than logistic regression or the neural network.

Learning curves for multiple breast cancer classification models
Learning curves. Model performance is compared across training sizes, giving a more complete view of stability and sample-efficiency.

Role and Implementation

I implemented the full machine learning workflow, including data preparation, manual logistic regression, model comparison, neural network training, evaluation visuals, and interpretation of classification performance.

Classification Workflow

Prepared the feature matrix and diagnosis labels, trained multiple supervised models, and compared predictive performance across model families.

Manual Model Implementation

Built a logistic regression workflow to demonstrate the underlying mechanics of binary classification, gradient descent, and cost-function optimization.

Model Evaluation

Used confusion matrices, classification reports, validation curves, learning curves, and bias-variance analysis to compare model behavior.

Tools

Python • NumPy • Pandas • Matplotlib • Scikit-learn • TensorFlow/Keras • XGBoost • Jupyter Notebook

Artifacts

The project artifacts include the notebook, source repository, visual outputs, and evaluation summaries used to communicate model behavior.

GitHub Repository

Source repository containing the notebook, project code, visual outputs, and documentation.

Open repository →

Notebook

Main Jupyter Notebook covering preprocessing, classification models, neural network training, and evaluation.

breast_cancer_detection_ml.ipynb

Visual Outputs

Selected visuals for dataset balance, feature separation, model performance, training behavior, and generalization analysis.

images/projects/breast-cancer/