Breast Cancer Predictor || Live Preview
A machine learning web application that predicts whether a breast mass is benign or malignant based on measurements from cytology lab results.
- Interactive web interface with adjustable measurements
- Real-time predictions
- Visual representation of measurements using radar charts
- Professional medical-grade predictions
- Python 3.8 or higher
- Git
- Clone the repository:
git clone https://github.com/prathamhanda/BreastCancer-Predictor.git
cd BreastCancer-Predictor
- Create and activate a virtual environment:
For Windows:
pip install numpy pandas scikit-learn streamlit plotly altair
python -m venv .venv
source .venv/Scripts/activate
python -m pip install streamlit
pip install plotly scikit-learn
python -m streamlit run app/main.py
For Linux/Mac:
python3 -m venv .venv
source .venv/bin/activate
- Install dependencies:
pip install -r requirements.txt
- Run the application:
# Make sure you're in the project root directory
python -m streamlit run app/main.py
- Open your web browser and go to:
http://localhost:8501
app/main.py
: Main application filedata/data.csv
: Dataset for trainingmodel/
: Contains trained model filesassets/
: CSS and other static filesconfusion_matrices/
: Contains model performance visualizations
- Launch the application using the instructions above
- Use the sliders in the sidebar to adjust measurements
- View the radar chart visualization
- Check the prediction results
If you see an error like:
Error: [Errno 13] Permission denied: '...\.venv\Scripts\python.exe'
Solutions:
- Close VS Code and any terminals using the
.venv
directory - Delete the existing
.venv
directory:rm -rf .venv
- Run VS Code as administrator
- Create the virtual environment in your user directory instead:
cd %USERPROFILE%
python -m venv breast-cancer-env
breast-cancer-env\Scripts\activate
cd path/to/Breast-Cancer-Predictor
If you see:
bash: streamlit: command not found
Solutions:
- Always use
python -m streamlit run app/main.py
instead ofstreamlit run app/main.py
- Make sure you're in the project root directory, not in the app directory
- Verify streamlit is installed:
pip list | grep streamlit
- Reinstall if needed:
pip install streamlit
If you see warnings like:
InconsistentVersionWarning: Trying to unpickle estimator LogisticRegression from version 1.2.2 when using version 1.6.1
Solutions:
- These warnings are expected and won't affect functionality
- If you want to eliminate warnings, install the exact version:
pip install scikit-learn==1.2.2
If you see:
UserWarning: X does not have valid feature names, but StandardScaler was fitted with feature names
Solution:
- This is an expected warning and won't affect the model's predictions
- The warning appears because of scikit-learn version differences
- Verify Virtual Environment:
# Should show (.venv) in prompt
echo %VIRTUAL_ENV%
- Check Installed Packages:
pip list
- Verify Working Directory:
# Should be in project root
pwd
- Clean Installation:
pip uninstall -r requirements.txt -y
pip install -r requirements.txt
- Port Already in Use: If port 8501 is in use, Streamlit will automatically try the next available port (8502, etc.)
The application includes three machine learning models for breast cancer prediction:
- Random Forest (96% accuracy)
- Support Vector Machine (98% accuracy)
- Logistic Regression (97% accuracy)
Confusion matrices and detailed performance metrics for each model are available in the confusion_matrices
directory.
This application is for educational purposes only and should not be used as a substitute for professional medical diagnosis.
- The model was trained using scikit-learn version 1.2.2
- Compatible with newer versions but will show version warnings
- Tested on Python 3.8+ and Windows 10/11