Breast Cancer Wisconsin (ANN) Prediction System
This repository contains a complete end-to-end Deep Learning project for classifying cell nuclei tumor features as Malignant or Benign using an Artificial Neural Network (ANN). The model is trained on the classic Breast Cancer Wisconsin dataset and deployed via a premium Streamlit web interface.
Features Overview
- Interactive Prediction Frontend: Input tumor diagnostic measurements through dynamically-ranged sliders categorized logically for ease of use.
- Color-Coded Prediction Callouts: Instant classification feedback (Red for Malignant, Green for Benign) along with confidence level metrics.
- Model Performance Metrics: Review validation statistics including Accuracy, Precision, Recall (Sensitivity), and F1-Score.
- Data Visualizations: Examine the training curves (Loss and Accuracy), confusion matrix, and permutation feature importances directly in the web app.
- Reproducible Pipeline: Fixed random seeds ensure deterministic and reproducible outputs across runs.
Project Structure
Breast-Cancer-Wisconsin-ANN/
├── data/
│ └── breast_cancer.csv
├── model/
│ ├── ann_model.keras
│ ├── scaler.pkl
│ ├── metrics.json
│ └── training_history.png
├── app.py
├── train.py
├── predict.py
├── preprocessing.py
├── requirements.txt
├── .gitignore
└── LICENSE
Installation Instructions
-
Clone or Navigate to the Directory:
cd Breast-Cancer-Wisconsin-ANN -
Set up a Virtual Environment (Optional but Recommended):
python -m venv venv # On Windows: .\venv\Scripts\activate # On macOS/Linux: source venv/bin/activate
-
Install Dependencies:
pip install -r requirements.txt
Usage Guide
- Train the Neural Network
Run
train.pyto preprocess the raw data, scale features, compile and fit the deep learning model (using early stopping), and evaluate on the test set:
python train.pyThis produces:
model/scaler.pklmodel/ann_model.kerasmodel/metrics.jsonmodel/training_history.png
- Launch the Streamlit Web Application
Run
app.pyto start the interactive prediction frontend on a local port:
streamlit run app.pyOpen the provided URL (usually http://localhost:8501) in your browser to interact with the application.
Model Architecture & Settings
The network consists of a feedforward Artificial Neural Network built using TensorFlow/Keras:
- Input Dimension: 30 features matching dataset columns.
- Hidden Layer 1: 128 neurons, Rectified Linear Unit (ReLU) activation, with 20% Dropout for regularization.
- Hidden Layer 2: 64 neurons, Rectified Linear Unit (ReLU) activation, with 20% Dropout.
- Output Layer: 1 neuron, Sigmoid activation (outputs probability of malignancy).
- Optimization: Adam Optimizer.
- Loss Function: Binary Crossentropy.
- Callbacks:
EarlyStoppingmonitoring validation loss with a patience of 10 epochs.
Dataset & Results
Dataset Summary The Breast Cancer Wisconsin dataset contains cell nuclei measurements computed from a digitized image of a fine needle aspirate (FNA) of a breast mass. It describes characteristics of the cell nuclei present in the image (radius, perimeter, area, texture, smoothness, compactness, concavity, concave points, symmetry, and fractal dimension).
Model Results (on 20% stratified test split)
- Test Accuracy: 99.12%
- Precision: 100.00% (0 false positives)
- Recall (Sensitivity): 97.62%
- F1-Score: 98.80%
License This project is licensed under the MIT License - see the LICENSE file for details.