-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
74 lines (61 loc) · 2.83 KB
/
app.py
File metadata and controls
74 lines (61 loc) · 2.83 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
62
63
64
65
66
67
68
69
70
71
72
73
74
import streamlit as st
import pandas as pd
import plotly.express as px
import plotly.graph_objects as go
@st.cache_data
def load_data(train_path, test_path):
train = pd.read_parquet(train_path)
test = pd.read_parquet(test_path)
return train, test
def main():
st.set_page_config(page_title="Bike Counters Dashboard", layout="wide")
st.title("🚴♂️ Bike Counters Dashboard")
st.markdown("Une exploration interactive des données de comptage de vélos.")
train_path = "data/train.parquet"
test_path = "data/final_test.parquet"
train, test = load_data(train_path, test_path)
st.header("📋 Aperçu des données")
st.write("**Train set** :", train.shape, " | **Test set** :", test.shape)
st.dataframe(train.head())
st.sidebar.header("🔍 Filtres")
if "site_name" in train.columns:
selected_site = st.sidebar.selectbox("Choisir un compteur :", sorted(train["site_name"].unique()))
filtered_df = train[train["site_name"] == selected_site]
else:
selected_site = None
filtered_df = train
if "date" in train.columns:
train["date"] = pd.to_datetime(train["date"])
min_date, max_date = train["date"].min().date(), train["date"].max().date()
selected_date = st.sidebar.slider("Choisir une plage de dates :", min_date, max_date, (min_date, max_date))
filtered_df = filtered_df[(filtered_df["date"] >= pd.to_datetime(selected_date[0])) & (filtered_df["date"] <= pd.to_datetime(selected_date[1]))]
st.header("📈 Visualisations interactives")
if "bike_log_count" in filtered_df.columns:
fig_hist = px.histogram(
filtered_df,
x="bike_log_count",
nbins=40,
color="site_name" if "site_name" in filtered_df.columns else None,
title="Distribution du nombre de vélos (log count)"
)
st.plotly_chart(fig_hist, use_container_width=True)
if "date" in filtered_df.columns and "bike_log_count" in filtered_df.columns:
fig_time = px.line(
filtered_df,
x="date",
y="bike_log_count",
color="site_name" if selected_site is None else None,
title=f"Évolution du trafic vélo {f'pour {selected_site}' if selected_site else ''}"
)
st.plotly_chart(fig_time, use_container_width=True)
numeric_cols = filtered_df.select_dtypes(include="number").columns
if len(numeric_cols) > 1:
corr = filtered_df[numeric_cols].corr()
fig_corr = px.imshow(corr, text_auto=True, color_continuous_scale="Viridis", title="Matrice de corrélation")
st.plotly_chart(fig_corr, use_container_width=True)
st.header("📊 Statistiques descriptives")
st.write(filtered_df.describe())
st.header("🧪 Données de test")
st.dataframe(test.head())
if __name__ == "__main__":
main()