-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
61 lines (45 loc) · 1.58 KB
/
app.py
File metadata and controls
61 lines (45 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import streamlit as st
import pandas as pd
import plotly.express as px
from Model.heat_model import train_and_predict
st.set_page_config(page_title="Urban Heat Island AI", layout="wide")
st.title("🌆🔥 Urban Heat Island AI")
st.write("AI-powered heat risk prediction for sustainable cities")
uploaded_file = st.file_uploader("Upload City Heat Dataset (CSV)", type=["csv"])
if uploaded_file:
df = pd.read_csv(uploaded_file)
st.subheader("📊 Raw Data")
st.dataframe(df)
df = train_and_predict(df)
st.subheader("🔥 Heat Risk Prediction")
fig = px.scatter_mapbox(
df,
lat="latitude",
lon="longitude",
color="heat_risk",
size="heat_risk",
color_continuous_scale="YlOrRd",
zoom=10,
mapbox_style="open-street-map",
title="Urban Heat Risk Map"
)
st.plotly_chart(fig, use_container_width=True)
st.subheader("🌱 Cooling Simulation")
trees_added = st.slider("Increase Green Cover (%)", 0, 30, 10)
df['simulated_risk'] = df['heat_risk'] - (trees_added * 0.8)
df['simulated_risk'] = df['simulated_risk'].clip(lower=0)
st.write("Heat risk after adding green cover:")
fig2 = px.scatter_mapbox(
df,
lat="latitude",
lon="longitude",
color="simulated_risk",
size="simulated_risk",
color_continuous_scale="Greens",
zoom=10,
mapbox_style="open-street-map",
title="Post-Intervention Heat Risk"
)
st.plotly_chart(fig2, use_container_width=True)
else:
st.info("👆 Upload a CSV file to start the demo")