How dianacmayorgar/stroke-prediction works
Project type and purpose
• This is a machine-learning–driven, data-visualization web application built with Streamlit.
• Purpose: provide interactive stroke-risk predictions using five pre-trained models (Logistic Regression, Naive Bayes, SVM, Decision Tree, Random Forest) plus model-explainability via LIME, and embed a Power BI dashboard for data insights.
File structure
• Top-level scripts:
• app.py (main Streamlit UI and orchestration)
• app(1).py, Stroke_prediction_project.py, Project_labelEncoding.py (data prep / alternative entry points)
• Directories:
• /models (five .pkl model files)
• /data (raw & cleaned CSV)
• Artifacts:
• Dashboard project – Stroke Prediction.pbix (Power BI file)
• Config: requirements.txt for Python dependencies.
Examining README insights
• Confirms stack: Python, Streamlit, pandas/numpy, matplotlib, tensorflow (possibly for LIME integration), lime, Power BI embed
• No microservices – single-process Streamlit app
• Supports: model inference, interpretability, embedded BI visualization.
Main components & relationships
a. Components
• User Interface (Streamlit)
• Input Form (Streamlit widgets)
• Data Preparation Module (Project_labelEncoding.py)
• Model Inference Module (loads .pkl from /models)
• Interpretability Module (LIME explainer)
• Power BI Embed (pbix dashboard via Streamlit iframe)
• Data Layer (CSV under /data)
• (Optional) Model Training Scripts (Stroke_prediction_project.py)
b. Relationships & data flows
1. User interacts with Input Form →
2. Input passed to Data Preparation →
3. Cleaned features forwarded to Model Inference →
• Models (.pkl) loaded from disk → produce predictions
4. Predictions & input → passed to LIME Explainer →
5. Prediction + explanation returned to UI →
6. UI renders charts, tables, text →
7. Separately, Power BI dashboard loaded in embedded frame
c. Architectural patterns & design principles
• Layered architecture: Presentation (UI), Application Logic (inference + LIME), Data Persistence (models + CSV).
• Single-process monolith (no microservices) but clear separation of concerns via modules.
• Extensibility: new models can be added to /models and discovered by the inference loader.
d. Key technologies & libraries
• Streamlit for UI & routing
• pandas/numpy for data handling
• pickle for model serialization
• lime for local interpretability
• matplotlib/plotly (if used) for on-the-fly plots
• Power BI embed via Streamlit components
Additional notes
• Optional branches: if a user chooses one of five models, show an internal switch/routing in the Inference module.
• Training script module (Stroke_prediction_project.py) as an optional “offline” component, separate from the real-time inference flow.