Riya1217 commited on
Commit
79a8ad0
·
verified ·
1 Parent(s): 2b6a921

Upload 2 files

Browse files
Files changed (1) hide show
  1. my_app_assignment.py +10 -6
my_app_assignment.py CHANGED
@@ -59,6 +59,8 @@ st.markdown("**Interpretation:** The scatter plot shows that as the total bill g
59
  # Plot 3 — Tip Percentage by Smoking Status
60
  fig3, ax3 = plt.subplots(figsize=(6,4)) # match Colab size
61
  sns.set_style("whitegrid") # match Colab style
 
 
62
  sns.boxplot(x="smoker", y="tip_pct", data=filtered, palette="Set2", ax=ax3)
63
 
64
  # Titles and labels
@@ -70,12 +72,14 @@ ax3.grid(axis="y", linestyle="--", alpha=0.7)
70
  # Display plot in Streamlit
71
  st.pyplot(fig3)
72
 
73
- # Calculate medians dynamically
74
  median_smokers = filtered[filtered["smoker"]=="Yes"]["tip_pct"].median()
75
  median_non_smokers = filtered[filtered["smoker"]=="No"]["tip_pct"].median()
76
 
77
- # Display interpretation
78
- st.markdown("**Interpretation:** The box plot and median values suggest that smoking status does not have a large impact on the average tip percentage. " \
79
- "The median tip percentage for smokers is 15,41%, and for non-smokers it is 15.56%." \
80
- " However, there are some instances where smokers gave significantly higher tips.")
81
-
 
 
 
59
  # Plot 3 — Tip Percentage by Smoking Status
60
  fig3, ax3 = plt.subplots(figsize=(6,4)) # match Colab size
61
  sns.set_style("whitegrid") # match Colab style
62
+
63
+ # Use filtered data from sidebar
64
  sns.boxplot(x="smoker", y="tip_pct", data=filtered, palette="Set2", ax=ax3)
65
 
66
  # Titles and labels
 
72
  # Display plot in Streamlit
73
  st.pyplot(fig3)
74
 
75
+ # --- Calculate medians dynamically ---
76
  median_smokers = filtered[filtered["smoker"]=="Yes"]["tip_pct"].median()
77
  median_non_smokers = filtered[filtered["smoker"]=="No"]["tip_pct"].median()
78
 
79
+ # --- Display interpretation dynamically ---
80
+ st.markdown(
81
+ f"**Interpretation:** The median tip percentage for smokers is {median_smokers:.2f}%, "
82
+ f"and for non-smokers it is {median_non_smokers:.2f}%. "
83
+ "The box plot suggests that smoking status does not have a large impact on the average tip percentage. "
84
+ "However, there are some instances where smokers gave significantly higher tips."
85
+ )