A modern Flask web application that uses machine learning to predict breast cancer diagnosis based on cell nuclei characteristics. Built with Python, Flask, and scikit-learn.
- AI-Powered Predictions: Uses Extra Trees Classifier with 100% F1 score on validation data
- Modern UI: Responsive design with Bootstrap 5, loading animations, and intuitive interface
- Real-time Analysis: Instant predictions with confidence scores and risk assessment
https://breast-cancer-flask-app.onrender.com/
- Algorithm: Extra Trees Classifier (automatically selected based on F1 score)
- Validation F1 Score: 1.0000 (100%)
- Test Accuracy: 100%
- Data Preprocessing: Z-score outlier removal, StandardScaler normalization
- Features: 30 cell nuclei measurements (mean, standard error, and worst values)
- Backend: Python Flask
- Machine Learning: Scikit-learn (Extra Trees, Random Forest, SVM, etc.)
- Frontend: HTML5, CSS3, Bootstrap 5, JavaScript
- Data Processing: NumPy, Pandas
- Model Persistence: Joblib
- Python 3.8 or higher
- pip (Python package installer)
git clone https://github.com/yourusername/breast-cancer-prediction-web.git
cd breast-cancer-prediction-webpython -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activatepip install -r requirements.txtpython app.pyNavigate to http://localhost:5000
- Data Loading: Uses the Wisconsin Breast Cancer dataset from scikit-learn
- Data Cleaning: Removes outliers using Z-score method (threshold: 3)
- Model Training: Trains 7 different ML algorithms and selects the best based on F1 score
- Model Selection: Extra Trees Classifier achieves perfect F1 score and is automatically selected
- Prediction: User inputs cell measurements β Model predicts Benign/Malignant with confidence
breast-cancer-prediction-web/
β
βββ app.py # Main Flask application
βββ requirements.txt # Python dependencies
βββ Procfile # For Heroku deployment
βββ runtime.txt # Python version for deployment
βββ README.md # Project documentation
βββ .gitignore # Git ignore file
β
βββ models/ # ML models (auto-generated)
β βββ breast_cancer_model.pkl
β βββ scaler.pkl
β
βββ templates/ # HTML templates
β βββ index.html # Main prediction page
β βββ about.html # About page
β
βββ static/ # Static files
βββ css/
β βββ style.css # Custom styles
βββ js/
βββ script.js # Frontend JavaScript
GET /- Main prediction interfacePOST /predict- Make prediction (JSON response)GET /about- About pageGET /api/model-info- Model information and metrics
curl -X POST http://localhost:5000/predict \
-d "mean radius=14.6" \
-d "mean texture=22.7" \
[... other 28 features]Response:
{
"prediction": "Benign",
"confidence": {
"benign": "71.0%",
"malignant": "29.0%"
},
"risk_level": "Low Risk",
"confidence_score": 0.71
}# Install Heroku CLI, then:
heroku create your-app-name
git push heroku main- Connect your GitHub repo to Render
- Select "Web Service"
- Build command:
pip install -r requirements.txt - Start command:
python app.py
- Connect GitHub repo to Railway
- Deploy automatically with zero configuration
python app.py
# Access via http://your-ip:5000IMPORTANT: This application is for educational and research purposes only. It should NOT be used for actual medical diagnosis or treatment decisions. Always consult with qualified healthcare professionals for medical advice.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Wisconsin Breast Cancer Dataset from UCI Machine Learning Repository
- Scikit-learn community for excellent ML tools
- Bootstrap team for the responsive UI framework
- Flask community for the lightweight web framework
β Star this repository if you found it helpful!