A full-stack, state-of-the-art web application that leverages multiple Machine Learning models (Random Forest, Gradient Boosting, Logistic Regression) to assist in breast cancer diagnosis. The application features advanced predictive analytics, model explainability (SHAP), dynamic visualizations (Histograms, PCA, Decision Boundaries), a custom model training dashboard, and an integrated AI chatbot named POTTI powered by Google's Gemini 2.5 API.
- Multi-Model Inference: Select between Random Forest, Gradient Boosting, and Logistic Regression for tailored predictions.
- SHAP Explainers: Interactive waterfall charts that explain exactly why a model made its prediction, breaking down the contribution of each individual feature.
- Data Explorer: Visualize the dataset with real-time Feature Scatter Plots, Correlation Heatmaps, Class Distribution Histograms, and 2D Principal Component Analysis (PCA).
- Decision Boundaries: View dynamic, generated 2D grids illustrating where models shift their predictions from Benign to Malignant.
- What-If Analysis: Interactively adjust patient features with sliders and instantly see the real-time impact on the diagnosis probabilities.
- Confidence Intervals: 90% bootstrap confidence intervals generated alongside deterministic predictions to gauge model certainty.
- Hyperparameter Tuning: Retrain the Random Forest, Gradient Boosting, or Logistic Regression models in real-time by adjusting sliders for
Trees,Max Depth,Min Samples Split,Learning Rate, andC. - Metrics Dashboard: View resulting validation metrics including Accuracy, Precision, Recall, F1-Score, and a customized Confusion Matrix Heatmap.
- Single & Batch Patient Processing: Upload CSVs for bulk testing or query individual patient data.
- Model Consensus: Side-by-side comparison of how all 3 models vote on a single set of inputs, complete with an "Agreement Score."
- PDF Report Generation: One-click download of a comprehensive, formatted
Patient_Report.pdfdetailing the prediction, feature values, and SHAP top contributors.
- A friendly, persistent floating assistant integrated with Gemini 2.5 Flash.
- Domain-aware: Knows about breast cancer diagnosis, the application’s models, SHAP, PCA, and platform features.
- Fluid UI: Includes typing indicators, user/AI message distinct styling, and smooth
framer-motiontransitions.
- Interactive Onboarding:
react-joyrideguided tour highlighting key platform elements on initial load. - Glassmorphism Design: Sleek translucent cards, gradient typography, and hover animations.
- System Theming: Native-feeling Dark and Light mode toggle with extensive CSS polish.
- Notifications: Informative toasts indicating background processes (e.g., "Model trained successfully").
- Skeleton Loaders: Prevents layout shift while API requests are resolving.
Frontend:
- React 19 + TypeScript
- Vite
- Material-UI (MUI components and system themes)
- Recharts (Interactive SVG visualizations)
- Framer Motion (Page and component transitions)
- React Joyride (Onboarding tour)
- jsPDF + AutoTable (PDF document generation)
Backend:
- Python 3 + Flask
- Scikit-Learn (Model definitions and evaluation)
- Pandas & NumPy (Data manipulation)
- SHAP (Model explainers)
- Google Generative AI SDK (Gemini API for POTTI chatbot)
git clone https://github.com/YOUR_USERNAME/breast-cancer-ai-studio.git
cd breast-cancer-ai-studioOpen a terminal and navigate to the backend directory:
cd backendCreate a virtual environment (optional but recommended):
python -m venv venv
# On Windows
venv\Scripts\activate
# On macOS/Linux
source venv/bin/activateInstall the required Python dependencies:
pip install -r requirements.txtYou need a Google Gemini API Key for the chatbot to work.
- Go to Google AI Studio and grab your API key.
- Inside the
backendfolder, you will find a.envfile (or create one). Add your key:
GEMINI_API_KEY=your_actual_api_key_hereMake sure you are still in the backend folder and your virtual environment is activated:
python app.pyThe Flask server will start on http://localhost:5000 and pre-compute PCA components and SHAP explainers.
Open a new terminal window and navigate to the frontend directory:
cd frontendInstall Node.js dependencies:
npm install
# Or if using legacy deps for React 19:
npm install --legacy-peer-depsStart the Vite development server:
npm run devThe frontend will be available at http://localhost:5173. Open this URL in your browser.
breast-cancer-ai-studio/
├── backend/
│ ├── app.py # Main Flask server & all API routes
│ ├── data.csv # Original Breast Cancer dataset
│ ├── train_model.py # Helper script to initially generate .pkl files
│ ├── scaler.pkl # Trained feature scaler
│ ├── breast_cancer_rf.pkl # Pre-trained Random Forest model
│ ├── breast_cancer_gb.pkl # Pre-trained Gradient Boosting model
│ ├── breast_cancer_lr.pkl # Pre-trained Logistic Regression model
│ ├── requirements.txt # Python dependencies
│ └── .env # Contains GEMINI_API_KEY
├── frontend/
│ ├── index.html # Entry point
│ ├── package.json
│ ├── vite.config.ts
│ └── src/
│ ├── App.tsx # Main routing, layout, and global providers
│ ├── App.css # Global glassmorphism & light mode styles
│ ├── shared.tsx # Global types, themes, API urls, navigation
│ ├── Chatbot.tsx # POTTI Gemini floating widget component
│ ├── OverviewPage.tsx # Dashboard with dataset and model statistics
│ ├── SinglePage.tsx # Predict single patient + SHAP + PDF Report
│ ├── BatchPage.tsx # Upload CSV for bulk predictions
│ ├── ComparePage.tsx # Multi-model consensus voting UI
│ ├── ExplorerPage.tsx # Histograms, PCA, Correlation, Decision Boundaries
│ ├── InsightsPage.tsx # Top feature importances
│ ├── WhatIfPage.tsx # Real-time feature adjustment sliders
│ └── TrainingPage.tsx # In-memory hyperparameter retuning dashboard
└── README.md
A💕A