Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -23,8 +23,8 @@ except Exception:
|
|
| 23 |
with st.sidebar:
|
| 24 |
selected = option_menu(
|
| 25 |
"Menu principal",
|
| 26 |
-
["🏁 EDA delay", "📈 EDA pricing", "🔮 API prediction"],
|
| 27 |
-
icons=["hourglass-split", "bar-chart-line", "cpu"],
|
| 28 |
menu_icon="cast",
|
| 29 |
default_index=0,
|
| 30 |
)
|
|
@@ -134,7 +134,73 @@ elif selected == "📈 EDA pricing":
|
|
| 134 |
except FileNotFoundError:
|
| 135 |
st.error("❌ Fichier CSV non trouvé : get_around_pricing_project.csv")
|
| 136 |
|
| 137 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
elif selected == "🔮 API prediction":
|
| 139 |
st.title("🔮 Prédiction du prix de location")
|
| 140 |
st.markdown("Remplis les informations suivantes pour obtenir une estimation du prix")
|
|
@@ -181,3 +247,4 @@ elif selected == "🔮 API prediction":
|
|
| 181 |
st.error(f"❌ Erreur {response.status_code} : {response.text}")
|
| 182 |
except Exception as e:
|
| 183 |
st.error(f"❌ Erreur lors de la requête : {e}")
|
|
|
|
|
|
| 23 |
with st.sidebar:
|
| 24 |
selected = option_menu(
|
| 25 |
"Menu principal",
|
| 26 |
+
["🏁 EDA delay", "📈 EDA pricing", "⏳ Seuil entre locations", "🔮 API prediction"],
|
| 27 |
+
icons=["hourglass-split", "bar-chart-line", "clock", "cpu"],
|
| 28 |
menu_icon="cast",
|
| 29 |
default_index=0,
|
| 30 |
)
|
|
|
|
| 134 |
except FileNotFoundError:
|
| 135 |
st.error("❌ Fichier CSV non trouvé : get_around_pricing_project.csv")
|
| 136 |
|
| 137 |
+
|
| 138 |
+
# ========== 3. SEUIL ENTRE LOCATIONS ==========
|
| 139 |
+
elif selected == "⏳ Seuil entre locations":
|
| 140 |
+
st.title("⏳ Analyse du seuil entre deux locations")
|
| 141 |
+
|
| 142 |
+
# Chargement des données
|
| 143 |
+
try:
|
| 144 |
+
dataset = pd.read_excel("get_around_delay_analysis.xlsx")
|
| 145 |
+
|
| 146 |
+
def resolved_rentals(threshold, scope):
|
| 147 |
+
if scope == "connect":
|
| 148 |
+
connect_late = dataset[
|
| 149 |
+
(dataset["delay_at_checkout_in_minutes"] > 0) &
|
| 150 |
+
(dataset["checkin_type"] == "connect")
|
| 151 |
+
]
|
| 152 |
+
resolved = connect_late[connect_late["delay_at_checkout_in_minutes"] <= threshold]
|
| 153 |
+
return round((len(resolved) / len(connect_late)) * 100, 2)
|
| 154 |
+
else:
|
| 155 |
+
late = dataset[dataset["delay_at_checkout_in_minutes"] > 0]
|
| 156 |
+
resolved = late[late["delay_at_checkout_in_minutes"] <= threshold]
|
| 157 |
+
return round((len(resolved) / len(late)) * 100, 2)
|
| 158 |
+
|
| 159 |
+
# Interface utilisateur
|
| 160 |
+
st.markdown("### Sélection du seuil")
|
| 161 |
+
col1, col2 = st.columns(2)
|
| 162 |
+
|
| 163 |
+
with col1:
|
| 164 |
+
seuil = st.slider("⏱️ Seuil entre deux locations (minutes)", 0, 240, 150, step=30)
|
| 165 |
+
with col2:
|
| 166 |
+
scope = st.radio("🚗 Type de véhicules concernés", ["all", "connect"],
|
| 167 |
+
format_func=lambda x: "Tous les véhicules" if x == "all" else "Connect uniquement")
|
| 168 |
+
|
| 169 |
+
resultat = resolved_rentals(seuil, scope)
|
| 170 |
+
st.success(f"✅ Avec un seuil de **{seuil} minutes**, environ **{resultat}%** des retards sont absorbés pour : **{scope}**.")
|
| 171 |
+
|
| 172 |
+
# Graphique de performance
|
| 173 |
+
import plotly.graph_objects as go
|
| 174 |
+
|
| 175 |
+
seuils = list(range(0, 241, 30))
|
| 176 |
+
all_vals = [resolved_rentals(s, "all") for s in seuils]
|
| 177 |
+
connect_vals = [resolved_rentals(s, "connect") for s in seuils]
|
| 178 |
+
|
| 179 |
+
fig = go.Figure()
|
| 180 |
+
fig.add_trace(go.Scatter(x=seuils, y=all_vals, name="Tous les véhicules", mode="lines+markers"))
|
| 181 |
+
fig.add_trace(go.Scatter(x=seuils, y=connect_vals, name="Connect uniquement", mode="lines+markers"))
|
| 182 |
+
fig.add_hline(y=50, line_dash="dash", line_color="red", annotation_text="Seuil 50%", annotation_position="top left")
|
| 183 |
+
|
| 184 |
+
fig.update_layout(
|
| 185 |
+
title="Taux de retards résolus selon le seuil appliqué",
|
| 186 |
+
xaxis_title="Seuil (minutes)",
|
| 187 |
+
yaxis_title="% de retards résolus",
|
| 188 |
+
yaxis_range=[0, 100],
|
| 189 |
+
template="simple_white"
|
| 190 |
+
)
|
| 191 |
+
|
| 192 |
+
st.plotly_chart(fig, use_container_width=True)
|
| 193 |
+
|
| 194 |
+
st.markdown("""
|
| 195 |
+
ℹ️ **Conseil produit** : un seuil entre **120 et 150 minutes** permet de résoudre une part significative des retards
|
| 196 |
+
sans bloquer inutilement les véhicules. Ajuster selon le volume futur de locations successives.
|
| 197 |
+
""")
|
| 198 |
+
|
| 199 |
+
except FileNotFoundError:
|
| 200 |
+
st.error("❌ Fichier Excel non trouvé : get_around_delay_analysis.xlsx")
|
| 201 |
+
|
| 202 |
+
|
| 203 |
+
# ========== 4. API PREDICTION ==========
|
| 204 |
elif selected == "🔮 API prediction":
|
| 205 |
st.title("🔮 Prédiction du prix de location")
|
| 206 |
st.markdown("Remplis les informations suivantes pour obtenir une estimation du prix")
|
|
|
|
| 247 |
st.error(f"❌ Erreur {response.status_code} : {response.text}")
|
| 248 |
except Exception as e:
|
| 249 |
st.error(f"❌ Erreur lors de la requête : {e}")
|
| 250 |
+
|