Zbehel commited on
Commit ·
cd5f1d2
1
Parent(s): b7a0d1c
Mettre tout sur le port 7860 et créer des onglets pour l'application Streamlit et le tableau de bord MLflow
Browse files- Dockerfile +2 -2
- app.py +45 -34
Dockerfile
CHANGED
|
@@ -23,7 +23,7 @@ RUN pip install -r /dependencies/requirements.txt
|
|
| 23 |
COPY . $HOME/app
|
| 24 |
|
| 25 |
# Exposer les ports pour Streamlit et MLflow
|
| 26 |
-
EXPOSE 7860
|
| 27 |
|
| 28 |
# Lancer Streamlit et le serveur de suivi MLflow
|
| 29 |
-
CMD ["sh", "-c", "streamlit run app.py --server.port 7860 --server.address 0.0.0.0 &
|
|
|
|
| 23 |
COPY . $HOME/app
|
| 24 |
|
| 25 |
# Exposer les ports pour Streamlit et MLflow
|
| 26 |
+
EXPOSE 7860
|
| 27 |
|
| 28 |
# Lancer Streamlit et le serveur de suivi MLflow
|
| 29 |
+
CMD ["sh", "-c", "streamlit run app.py --server.port 7860 --server.address 0.0.0.0 & mlflow server --host 0.0.0.0 --port 7860"]
|
app.py
CHANGED
|
@@ -11,53 +11,64 @@ df.rename(columns={'delay_at_checkout_in_minutes': 'delay'}, inplace=True)
|
|
| 11 |
|
| 12 |
df['late_checkin'] = df['delay'] > 0
|
| 13 |
|
| 14 |
-
#
|
| 15 |
-
st.
|
| 16 |
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
|
| 21 |
-
|
|
|
|
|
|
|
| 22 |
|
| 23 |
-
|
| 24 |
|
| 25 |
-
|
| 26 |
-
- scope: should we enable the feature for all cars?, only Connect cars?
|
| 27 |
|
| 28 |
-
|
| 29 |
-
|
| 30 |
|
|
|
|
|
|
|
| 31 |
|
| 32 |
-
# Visualiser les données
|
| 33 |
-
fig = px.histogram(df, x='delta', title='Distribution of Delays Between Rentals')
|
| 34 |
-
st.plotly_chart(fig)
|
| 35 |
|
| 36 |
-
# Sélection du seuil et du scope
|
| 37 |
-
threshold = st.slider("Select the minimum delay threshold (in hours)", 0, 12, 2)
|
| 38 |
-
scope = st.selectbox("Select the scope", ["All cars", "Connect cars"])
|
| 39 |
|
| 40 |
-
# Filtrer les données en fonction du scope
|
| 41 |
-
if scope == "Connect cars":
|
| 42 |
-
|
| 43 |
|
| 44 |
-
# Calculer le pourcentage de réservations affectées
|
| 45 |
-
affected_rentals = df[df['
|
| 46 |
-
total_rentals = df.shape[0]
|
| 47 |
-
share_affected_rentals = affected_rentals / total_rentals * 100
|
| 48 |
|
| 49 |
-
# Afficher les résultats
|
| 50 |
-
st.write(f"Percentage of rentals potentially affected by the feature: {share_affected_rentals:.2f}%")
|
| 51 |
|
| 52 |
-
# Analyser les retards
|
| 53 |
-
late_checkins = df[df['late_checkin'] == True].shape[0]
|
| 54 |
-
total_checkins = df.shape[0]
|
| 55 |
-
share_late_checkins = late_checkins / total_checkins * 100
|
| 56 |
|
| 57 |
-
st.write(f"Share of late check-ins: {share_late_checkins:.2f}%")
|
| 58 |
|
|
|
|
|
|
|
|
|
|
| 59 |
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
st.
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
df['late_checkin'] = df['delay'] > 0
|
| 13 |
|
| 14 |
+
# Créer des onglets
|
| 15 |
+
tab1, tab2 = st.tabs(["Getaround Rentals Analysis", "MLflow Dashboard"])
|
| 16 |
|
| 17 |
+
with tab1:
|
| 18 |
+
# Titre du tableau de bord
|
| 19 |
+
st.title("Getaround Rentals Analysis")
|
| 20 |
|
| 21 |
+
# Description
|
| 22 |
+
st.markdown("""
|
| 23 |
+
In order to mitigate those issues we’ve decided to implement a minimum delay between two rentals. A car won’t be displayed in the search results if the requested checkin or checkout times are too close from an already booked rental.
|
| 24 |
|
| 25 |
+
It solves the late checkout issue but also potentially hurts Getaround/owners revenues: we need to find the right trade off.
|
| 26 |
|
| 27 |
+
Our Product Manager still needs to decide:
|
|
|
|
| 28 |
|
| 29 |
+
- threshold: how long should the minimum delay be?
|
| 30 |
+
- scope: should we enable the feature for all cars?, only Connect cars?
|
| 31 |
|
| 32 |
+
In order to help them make the right decision, they are asking you for some data insights. Here are the first analyses they could think of, to kickstart the discussion. Don’t hesitate to perform additional analysis that you find relevant.
|
| 33 |
+
""")
|
| 34 |
|
| 35 |
+
# Visualiser les données
|
| 36 |
+
fig = px.histogram(df, x='delta', title='Distribution of Delays Between Rentals')
|
| 37 |
+
st.plotly_chart(fig)
|
| 38 |
|
| 39 |
+
# Sélection du seuil et du scope
|
| 40 |
+
threshold = st.slider("Select the minimum delay threshold (in hours)", 0, 12, 2)
|
| 41 |
+
scope = st.selectbox("Select the scope", ["All cars", "Connect cars"])
|
| 42 |
|
| 43 |
+
# Filtrer les données en fonction du scope
|
| 44 |
+
if scope == "Connect cars":
|
| 45 |
+
df = df[df['car_type'] == 'Connect']
|
| 46 |
|
| 47 |
+
# Calculer le pourcentage de réservations affectées
|
| 48 |
+
affected_rentals = df[df['delta'] < threshold].shape[0]
|
| 49 |
+
total_rentals = df.shape[0]
|
| 50 |
+
share_affected_rentals = affected_rentals / total_rentals * 100
|
| 51 |
|
| 52 |
+
# Afficher les résultats
|
| 53 |
+
st.write(f"Percentage of rentals potentially affected by the feature: {share_affected_rentals:.2f}%")
|
| 54 |
|
| 55 |
+
# Analyser les retards
|
| 56 |
+
late_checkins = df[df['late_checkin'] == True].shape[0]
|
| 57 |
+
total_checkins = df.shape[0]
|
| 58 |
+
share_late_checkins = late_checkins / total_checkins * 100
|
| 59 |
|
| 60 |
+
st.write(f"Share of late check-ins: {share_late_checkins:.2f}%")
|
| 61 |
|
| 62 |
+
# Visualiser les données
|
| 63 |
+
fig = px.histogram(df, x='delta', title='Distribution of Delays Between Rentals')
|
| 64 |
+
st.plotly_chart(fig)
|
| 65 |
|
| 66 |
+
# Analyser les cas problématiques résolus
|
| 67 |
+
solved_cases = df[(df['delta'] < threshold) & (df['late_checkin'] == True)].shape[0]
|
| 68 |
+
st.write(f"Number of problematic cases solved by the feature: {solved_cases}")
|
| 69 |
|
| 70 |
+
with tab2:
|
| 71 |
+
st.title("MLflow Dashboard")
|
| 72 |
+
st.markdown("""
|
| 73 |
+
<iframe src="http://0.0.0.0:7860" width="100%" height="800"></iframe>
|
| 74 |
+
""", unsafe_allow_html=True)
|