Spaces:
Build error
Build error
Create modules/visuals.py
Browse files- modules/visuals.py +30 -0
modules/visuals.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import seaborn as sns
|
| 3 |
+
import matplotlib.pyplot as plt
|
| 4 |
+
|
| 5 |
+
def display_dashboard(df):
|
| 6 |
+
st.subheader("📊 System Summary")
|
| 7 |
+
col1, col2, col3 = st.columns(3)
|
| 8 |
+
col1.metric("Total Poles", df.shape[0])
|
| 9 |
+
col2.metric("🚨 Red Alerts", df[df['AlertLevel']=="Red"].shape[0])
|
| 10 |
+
col3.metric("⚡ Power Issues", df[df['PowerSufficient']=="No"].shape[0])
|
| 11 |
+
|
| 12 |
+
def display_charts(df):
|
| 13 |
+
st.subheader("⚙️ Energy Generation Trends")
|
| 14 |
+
st.bar_chart(df.set_index("PoleID")[["SolarGen(kWh)", "WindGen(kWh)"]])
|
| 15 |
+
st.subheader("📉 Tilt vs Vibration")
|
| 16 |
+
st.scatter_chart(df.rename(columns={"Tilt(°)": "Tilt", "Vibration(g)": "Vibration"}).set_index("PoleID")[["Tilt", "Vibration"]])
|
| 17 |
+
|
| 18 |
+
def display_heatmap(df):
|
| 19 |
+
st.subheader("🔥 Correlation Heatmap")
|
| 20 |
+
# Select numerical columns for correlation
|
| 21 |
+
numerical_cols = ["SolarGen(kWh)", "WindGen(kWh)", "Tilt(°)", "Vibration(g)"]
|
| 22 |
+
corr_matrix = df[numerical_cols].corr()
|
| 23 |
+
|
| 24 |
+
# Create heatmap using seaborn
|
| 25 |
+
fig, ax = plt.subplots(figsize=(8, 6))
|
| 26 |
+
sns.heatmap(corr_matrix, annot=True, cmap="coolwarm", vmin=-1, vmax=1, center=0, ax=ax)
|
| 27 |
+
plt.title("Correlation Heatmap of Pole Metrics")
|
| 28 |
+
|
| 29 |
+
# Display in Streamlit
|
| 30 |
+
st.pyplot(fig)
|