BreastNet
A neural network for early breast cancer detection from clinical measurements.
Classifies tissue samples as benign or malignant from nine numerical features. The project builds the full pipeline: loading, preprocessing, network design, training, evaluation and result visualization.
README · rendered from GitHub
BreastNet: Early Breast Cancer Detection
BreastNet is a neural network based binary classifier designed to detect breast cancer at an early stage. Using nine numerical clinical features from the Breast Cancer Dataset (Kaggle: yasserh), it predicts whether a tumor is benign or malignant.
1. Problem Statement
Breast cancer is a major global health issue and early detection is critical for improving survival rates. Traditional diagnosis involves manual interpretation of cell measurements, which can be time consuming and sometimes inconsistent.
Goal: Develop a neural network that can automatically classify tumors as benign or malignant based on structured numeric data, offering a fast and reliable clinical decision support tool.
Why this matters:
- Early-stage detection significantly improves treatment outcomes.
- Algorithmic assistance can support pathologists and clinicians.
- Machine learning can analyze patterns too subtle for manual inspection.
2. Dataset Description
Source: Kaggle (Breast Cancer Dataset by yasserh) Link: https://www.kaggle.com/datasets/yasserh/breast-cancer-dataset
Dataset Details
-
Total Samples: 699
-
Total Features: 10
-
Usable Features for Learning: 9
-
Target Label Column: Class
- 2 → Benign
- 4 → Malignant
Feature List
These features describe visual and morphological characteristics of cell nuclei:
- Clump Thickness
- Uniformity of Cell Size
- Uniformity of Cell Shape
- Marginal Adhesion
- Single Epithelial Cell Size
- Bare Nuclei
- Bland Chromatin
- Normal Nucleoli
- Mitoses
The Id column is removed because it does not contain predictive information.
Nature of Features
All nine features are integer scores between 1 and 10. Higher values generally correlate with higher malignancy risk.
3. Data Preprocessing Workflow
Your notebook follows a structured preprocessing pipeline:
Step 1: Load Dataset
Load CSV into pandas and inspect for missing values.
Step 2: Drop the Id Column
Id is irrelevant for prediction.
Step 3: Handle Missing Values
Commonly found in “Bare Nuclei”. Rows with missing values are removed or corrected.
Step 4: Encode the Class Label
Convert (2, 4) → (0, 1):
- 0 → Benign
- 1 → Malignant
Step 5: Train Test Split
Example: 80 percent training, 20 percent testing.
Step 6: Feature Scaling
Apply StandardScaler:
- Ensures all features are on similar scales
- Improves convergence during training
Step 7: Model Input Preparation
Convert scaled arrays into formats suitable for the neural network training loop.
4. Model Architecture (BreastNet)
BreastNet is a simple feed forward neural network built from scratch or using deep learning libraries.
Architecture Summary
Input Layer:
- 9 neurons (one per feature)
Hidden Layer 1:
- ~16 or 32 neurons
- Activation: ReLU
Hidden Layer 2 (optional):
- ~8 or 16 neurons
- Activation: ReLU
Output Layer:
- 1 neuron
- Activation: Sigmoid
- Outputs probability of malignancy
Why This Architecture?
- Dataset is small, so simple architecture avoids overfitting
- ReLU speeds up training
- Sigmoid enables true binary probability output
- Easy to interpret
Loss and Optimization
- Loss: Binary Cross Entropy
- Optimizer: Gradient Descent or Adam-like strategy
- Epochs: ~1300 (your notebook trained until convergence)
- Learning Rate: around 0.03
5. Training Behavior and Convergence
Your model shows a clear improvement in testing cost as training progresses:
Example Logs (taken from your notebook):
-
Epoch 0:
- Train Cost = 0.8021
- Test Cost = 0.9719
-
Epoch 300:
- Train Cost = 0.1148
- Test Cost = 0.1515
-
Epoch 700:
- Train Cost = 0.0614
- Test Cost = 0.1170
-
Epoch 990+:
- Best test costs reach 0.1122
This demonstrates strong convergence and stable learning.
6. Final Evaluation Metrics (Extracted From Notebook)
Confusion Matrix
TP: 26
TN: 83
FP: 5
FN: 0
Direct Results
- Final Test Cost: 0.1122
- F1 Score: 0.9123
Derived Performance Metrics
Accuracy: (26 + 83) / (26 + 83 + 5 + 0) = 109 / 114 = 95.6 percent
Precision: 26 / (26 + 5) = 83.87 percent
Recall (Sensitivity): 26 / (26 + 0) = 100 percent
Specificity: 83 / (83 + 5) = 94.3 percent
F1 Score: = 91.23 percent
Interpretation
- Zero false negatives → the model never misses malignant cases
- High recall → clinically important for early cancer detection
- High specificity → good at distinguishing benign cases
- F1 score balances both precision and recall
This is a strong result given the small dataset size.
7. Key Observations
- The model achieves excellent recall, critical for cancer screening.
- Training stabilizes after about 900 epochs, with minimal test cost.
- Misclassifications mainly occur as false positives, which is safer than false negatives.
- Neural network captures relationships between features effectively.
- Scaling features greatly helps training stability.
8. Project Conclusion
BreastNet demonstrates the effectiveness of neural networks in early breast cancer detection using structured numeric medical data.
The model:
- Achieves 95.6 percent accuracy
- Achieves 100 percent sensitivity to malignant cases
- Maintains strong generalization on test data
- Provides fast and consistent predictions
This project showcases how AI can augment medical decision making in real clinical settings.
9. Limitations
- Dataset is small and may not fully generalize to real-world populations.
- Based solely on tabular data; real diagnosis typically uses imaging (mammograms).
- The model is not medically validated.
- Potential overfitting due to small dataset and long training time.
10. Future Improvements
- Incorporate deeper networks or regularization techniques
- Add ROC AUC calculation and threshold tuning
- Use oversampling or class weights to handle imbalance
- Combine tabular data with image based models
- Deploy as a web-based prediction tool
- Validate on additional breast cancer datasets
11. Tools and Technologies Used
- Python
- pandas, NumPy
- StandardScaler
- Custom Neural Network
- Matplotlib for cost/metric visualization
- Jupyter Notebook
- Kaggle Breast Cancer Dataset
More in AI / ML
Related projects
Private repoAI / MLSummer 2026Trans-Neptunian Object Detection
A spatiotemporal U-Net that finds faint moving objects in telescope image sequences.
- PyTorch
- Python
- HDF5
- CANFAR
AI / ML2023SkinSense: Skin Cancer Classifier
An ensemble of five models labels a lesion as benign or malignant from one RGB image.
- Python
- Scikit-learn
- XGBoost
- LightGBM
AI / ML2025RecycleVision
EfficientNetB0 transfer learning sorts waste into six recyclable categories.
- Python
- TensorFlow
- Keras
- EfficientNetB0