A polished, interactive Streamlit dashboard for exploring sleep health and lifestyle data. Upload the Kaggle Sleep Health & Lifestyle Dataset (or any compatible CSV) and get instant visualizations, evidence-backed insights, and AI-powered interpretations — all in your browser.
Built as a portfolio/recruitment project demonstrating clean architecture, typed Python, Plotly interactivity, and Anthropic API integration.
- CSV upload with validation — friendly error messages if required columns are missing
- Summary metrics — average sleep, stress, daily steps, and disorder prevalence at a glance
- Three interactive Plotly charts
- Stress vs Sleep Quality scatter with OLS trendline and BMI colour coding
- Average Sleep Duration by BMI Category (bar)
- Pearson correlation heatmap for all numeric features
- Evidence-backed insight cards — each card plugs in real computed values (Pearson r, quartile means, intervention group %)
- AI "Ask the Data" box — powered by Claude, streamed in real time, with a compact dataset summary injected as context
| Layer | Tool |
|---|---|
| UI | Streamlit |
| Charts | Plotly Express |
| Data | pandas, numpy, scipy |
| AI | Anthropic Python SDK (Claude) |
Requires uv.
git clone <repo-url>
cd health_insights
uv sync # creates .venv and installs all pinned depsmkdir -p .streamlit
echo 'ANTHROPIC_API_KEY = "sk-ant-..."' > .streamlit/secrets.tomlThe AI box is silently disabled if the key is absent — the rest of the app works without it.
uv run streamlit run app.pyThen upload Sleep_health_and_lifestyle_dataset.csv (or any CSV with the required columns).
uv runautomatically uses the isolated.venv— nosource .venv/bin/activateneeded.
Sleep Duration, Quality of Sleep, Physical Activity Level,
Stress Level, BMI Category, Heart Rate, Daily Steps, Sleep Disorder
Sleep Health and Lifestyle Dataset — Kaggle, by Laksika Tharmalingam. 374 synthetic records covering sleep metrics, lifestyle factors, and cardiovascular health indicators.
health_insights/
├── app.py # Streamlit UI — imports → config → upload → metrics → charts → AI
├── utils.py # Pure functions: loading, stats, insight maths, chart builders
├── pyproject.toml # uv project manifest and dependency list
├── uv.lock # pinned lockfile (commit this)
├── requirements.txt # pip fallback
└── README.md
utils.py contains zero Streamlit calls and is independently testable.
MIT
