CoolFace
Modelpublic

NethranjaliSE/Breast-Cancer-detection-using-ML-Algorithm

sourceHugging Facemitupdated 4mo agoView on Hugging Face
0likes
Model Card

๐ŸŽ—๏ธ Breast Cancer Detection Ensemble Pipeline

An optimized, production-ready machine learning pipeline featuring a Soft-Voting Ensemble Classifier. This model is trained on clinical data to distinguish between malignant and benign tumors with high sensitivity (recall), minimizing false negatives in diagnostic screening.

This repository structure is modeled after the methodology discussed in "Comparison of ML Algorithms for Breast Cancer Prediction" (CTEMS 2018), expanding the baseline framework to a robust 5-model ensemble architecture with automated pipeline scaling.


๐Ÿ“Š Model Description

The model utilizes a Soft-Voting architecture that aggregates predicted class probabilities across five diverse individual base estimators. Every individual classifier is encapsulated within a leakage-free preprocessing pipeline featuring automated standardization using StandardScaler.

Component Estimators

  1. 1.Random Forest Classifier
  2. 2.72 estimators
  3. 3.Balanced class weights
  1. 1.k-Nearest Neighbors (kNN)
  2. 2.Euclidean distance metric
  3. 3.k = 5
  1. 1.Gaussian Naive Bayes
  2. 2.Probabilistic baseline classifier
  1. 1.Support Vector Classifier (SVC)
  2. 2.rbf kernel
  3. 3.Probability estimation enabled
  1. 1.Logistic Regression
  2. 2.Regularized linear classifier
  3. 3.Balanced class distributions

๐Ÿ“ˆ Dataset & Training Architecture

  • โ€”Dataset Source: Wisconsin Diagnosis Breast Cancer (WDBC) โ€” UCI Machine Learning Repository
  • โ€”Instances: 569 samples
  • โ€”357 Benign
  • โ€”212 Malignant
  • โ€”Features: 30 real-valued clinical features extracted from digitized FNA images
  • โ€”Split Strategy: Stratified train-test split
  • โ€”Training: 398 samples
  • โ€”Testing: 171 samples

The pipeline uses:

  • โ€”StratifiedKFold cross-validation
  • โ€”Leakage-free preprocessing
  • โ€”Automated scaling pipelines

โšก Performance Metrics

Evaluation prioritizes Recall (Sensitivity) to reduce false negatives while maintaining strong overall classification accuracy.

ModelAccuracyPrecisionRecallF1-ScoreROC-AUC
Ensemble (Soft Voting)0.97660.97250.99070.98150.9972
Random Forest0.96490.96330.98130.97220.9936
kNN0.95910.95450.98130.96770.9877
Support Vector Machine0.97660.97250.99070.98150.9974
Logistic Regression0.97660.97250.99070.98150.9969
Naive Bayes0.95910.95450.98130.96770.9892
Note: Results may vary slightly depending on package versions and random seeds.

๐Ÿ’ป Installation

Dependencies

text
scikit-learn>=1.0
numpy
pandas
joblib
huggingface_hub

Install dependencies:

bash
pip install scikit-learn numpy pandas joblib huggingface_hub

๐Ÿš€ Dynamic Inference Example

You can directly download and run the trained pipeline from Hugging Face Hub.

python
import joblib
import pandas as pd
from huggingface_hub import hf_hub_download

# Download model pipeline
model_path = hf_hub_download(
    repo_id="NethranjaliSE/Breast-Cancer-detection-using-ML-Algorithm",
    filename="ensemble_soft_voting.pkl"
)

# Load pipeline
pipeline = joblib.load(model_path)

# Example sample input (30 WDBC features)
sample_data = [[
    14.12, 19.28, 91.96, 654.8, 0.096, 0.11, 0.08, 0.04, 0.18, 0.06,
    0.25, 0.89, 1.82, 24.3, 0.006, 0.02, 0.02, 0.01, 0.01, 0.003,
    16.26, 25.67, 107.26, 880.5, 0.132, 0.21, 0.19, 0.09, 0.28, 0.08
]]

feature_names = (
    pipeline.feature_names_in_
    if hasattr(pipeline, "feature_names_in_")
    else None
)

input_df = pd.DataFrame(sample_data, columns=feature_names)

# Predict
prediction = pipeline.predict(input_df)
probabilities = pipeline.predict_proba(input_df)[0]

diagnosis = (
    "Benign (Low Risk)"
    if prediction[0] == 1
    else "Malignant (High Risk)"
)

print(f"Diagnostic Assessment: {diagnosis}")

print(
    f"Confidence Matrix -> "
    f"Malignant: {probabilities[0]:.4f} | "
    f"Benign: {probabilities[1]:.4f}"
)

๐Ÿ“‚ Repository Structure

text
.
โ”œโ”€โ”€ ensemble_soft_voting.pkl
โ”œโ”€โ”€ training_pipeline.ipynb
โ”œโ”€โ”€ requirements.txt
โ””โ”€โ”€ README.md

โš ๏ธ Limitations & Intended Use

This model is developed strictly for:

  • โ€”Academic research
  • โ€”Educational purposes
  • โ€”Machine learning experimentation
  • โ€”Pipeline prototyping

It is NOT approved for:

  • โ€”Clinical deployment
  • โ€”Medical diagnosis
  • โ€”Real-world healthcare decision-making

All diagnostic decisions must be performed by qualified medical professionals using certified medical systems.


๐Ÿ“œ Citations

Research Reference

bibtex
@article{street1993nuclear,
  title={Nuclear feature extraction for breast tumor diagnosis},
  author={Street, W.N. and Wolberg, W.H. and Mangasarian, O.L.},
  journal={IS&T/SPIE Biomedical Imaging},
  year={1993}
}

Dataset Reference

  • โ€”UCI Machine Learning Repository
  • โ€”Breast Cancer Wisconsin (Diagnostic) Dataset

๐Ÿค Acknowledgements

Special thanks to:

  • โ€”UCI Machine Learning Repository
  • โ€”Scikit-learn contributors
  • โ€”Hugging Face Hub
  • โ€”Open-source ML research community

๐Ÿง  Model Author

Sachini Praboda Nethranjali Electronic and Computer Science Undergraduate University of Kelaniya, Sri Lanka