Stroke Risk Analysis with Preswald

Amrutha GujjarAmrutha Gujjarβ€’β€’3 min read

Category: Community


We're thrilled to feature Miray Ozcan in this edition of the Preswald Community Showcase! πŸŽ‰ Miray has built a health-focused Preswald app that explores the risk factors associated with strokes, allowing users to interact with real medical data and uncover patterns that influence stroke outcomes.

🌟 Project Overview

πŸ“Š Preswald for Healthcare and Risk Modeling

This blog demonstrates how Preswald can power dashboards that visualize and interpret clinical datasets. Miray’s app provides stroke risk insights using interactive visualizations that help interpret how lifestyle, demographics, and health conditions relate to risk.

Project Name: Stroke Risk Explorer
Built by: Miray Ozcan
Dataset: Stroke Prediction Dataset
Live App: Stroke Risk Explorer

πŸ“Š Description

Miray's app includes:

  • ❀️ Interactive charts showing stroke risk by gender, age, and smoking status

  • 🧠 Visual breakdowns of stroke cases vs comorbidities like hypertension

  • πŸ“ˆ Sliders to filter users by glucose level, BMI, and heart condition

  • πŸ“Š Correlation plots for early stroke prediction features

Preswald enables seamless development of health informatics dashboards, and Miray’s app is a powerful example of its application in medical data analysis.


πŸš€ Code Snippets

Load and Filter Stroke Dataset

from preswald import connect, get_df, text, table

connect()
df = get_df('stroke_data')

text("# Stroke Risk Dashboard")
text("Explore risk factors for strokes using demographic and health attributes.")
table(df.head())

Bar Chart: Stroke Cases by Gender

import plotly.express as px
from preswald import plotly

fig = px.bar(df.groupby('gender')['stroke'].sum().reset_index(),
             x='gender', y='stroke',
             title='Stroke Cases by Gender')
plotly(fig)

Scatter Plot: Age vs Avg Glucose by Stroke

fig = px.scatter(df, x='age', y='avg_glucose_level', color='stroke',
                 title='Age vs Glucose Level Colored by Stroke Risk')
plotly(fig)

πŸ“Š Key Insights

  • πŸ§“ Older individuals have higher stroke occurrence rates

  • πŸ’‰ High glucose levels and hypertension correlate with elevated stroke risk

  • 🚬 Smoking status plays a significant role in stroke outcomes


πŸ“Š What is Preswald?

Preswald is an open-source framework for building data apps, dashboards, and internal tools with just Python. It enables developers to turn any analysis script into a shareable app, with UI components like tables, charts, and forms.

Key Features

  • Turn healthcare analytics into real-time visual dashboards

  • Automatic reactivity with slider and dropdown inputs

  • Lightweight sharing and deployment

  • Pre-built chart components and filters


πŸš€ Getting Started

Installation

pip install preswald

Start a Project

preswald init my_project
cd my_project
preswald run

Deploy

preswald deploy --target structured

Huge Thanks to Miray Ozcan!

A huge thank you to Miray Ozcan for creating a health-empowering dashboard that helps people understand stroke risks better. Connect with Miray here:

Want to Contribute?

Got a cool idea for a Preswald app? We'd love to see it! Get started here: https://github.com/StructuredLabs/preswald and get featured in our next Community Showcase.

Happy building! πŸš€