Riya1217 commited on
Commit
b7c11ef
·
verified ·
1 Parent(s): 8a04803

Upload my_app_assignment.py

Browse files
Files changed (1) hide show
  1. my_app_assignment.py +10 -3
my_app_assignment.py CHANGED
@@ -46,9 +46,16 @@ ax2.set_xlabel("Total Bill")
46
  ax2.set_ylabel("Tip Percentage (%)")
47
  ax2.grid(True, linestyle="--", alpha=0.5)
48
  st.pyplot(fig2)
49
- st.markdown("**Interpretation:** The scatter plot shows that as the total bill goes up, the tip percentage generally goes down." \
50
- " This means people(both male and female) tend to tip a smaller percentage on larger bills. " \
51
- "There are a few cases with very high tip percentages, especially on smaller bills.")
 
 
 
 
 
 
 
52
 
53
  # Plot 3 — Tip Percentage by Smoking Status
54
  fig3, ax3 = plt.subplots(figsize=(6,4)) # match Colab size
 
46
  ax2.set_ylabel("Tip Percentage (%)")
47
  ax2.grid(True, linestyle="--", alpha=0.5)
48
  st.pyplot(fig2)
49
+ # --- Calculate dynamic interpretation ---
50
+ avg_tip_male = filtered[filtered["sex"]=="Male"]["tip_pct"].mean()
51
+ avg_tip_female = filtered[filtered["sex"]=="Female"]["tip_pct"].mean()
52
+
53
+ st.markdown(
54
+ f"**Interpretation:** For the selected filters, the average tip percentage for males is {avg_tip_male:.2f}% "
55
+ f"and for females is {avg_tip_female:.2f}%. "
56
+ "The scatter plot shows that as the total bill increases, tip percentage tends to decrease, "
57
+ "although there are some cases where smaller bills have higher tip percentages."
58
+ )
59
 
60
  # Plot 3 — Tip Percentage by Smoking Status
61
  fig3, ax3 = plt.subplots(figsize=(6,4)) # match Colab size