SanaAdeel commited on
Commit
7375b16
·
verified ·
1 Parent(s): 6cabea8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -28
app.py CHANGED
@@ -10,23 +10,23 @@ def load_data(file_url):
10
  return pd.read_excel(file_path, engine='openpyxl')
11
 
12
  # Function to generate the weekly menu
13
- def generate_menu(data, season, sub_category_pref, outings, bmi_category):
14
  # Filter season data
15
  season_data = data[(data['Season'] == season) | (data['Season'] == 'All Seasons')]
16
 
17
  # Adjust the menu based on BMI category
18
  if bmi_category == "Underweight":
19
  # Suggest high-calorie dishes like meat, rice, and calorie-dense vegetables
20
- preferred_dishes = ['Meat', 'Rice', 'Sabzi', 'Chicken']
21
  elif bmi_category == "Normal Weight":
22
  # Balanced meals with a variety of dishes
23
- preferred_dishes = ['Sabzi', 'Rice', 'Daal', 'Chicken', 'Fish']
24
  elif bmi_category == "Overweight":
25
  # Focus on lean proteins and vegetables, limiting carbs
26
- preferred_dishes = ['Sabzi', 'Chicken', 'Fish', 'Meat']
27
  else: # Obese category
28
  # Focus on lean proteins, vegetables, and smaller portions of carbs
29
- preferred_dishes = ['Sabzi', 'Daal', 'Chicken', 'Fish']
30
 
31
  # Select dishes based on the BMI category and preferences
32
  menu = []
@@ -43,13 +43,17 @@ def generate_menu(data, season, sub_category_pref, outings, bmi_category):
43
  side_dishes = data[data['Course'] == 'Side Dish'].sample(2).to_dict('records')
44
  menu.extend(side_dishes)
45
 
46
- # Generate the menu and calculate total cost
47
  menu_df = pd.DataFrame(menu)
 
 
48
  lunch_menu = menu_df.iloc[:len(menu_df)//2]
49
  dinner_menu = menu_df.iloc[len(menu_df)//2:]
50
 
 
51
  total_cost = menu_df["Cost per 4 persons"].sum()
52
 
 
53
  lunch_menu = lunch_menu[["Name"]]
54
  dinner_menu = dinner_menu[["Name"]]
55
 
@@ -57,25 +61,23 @@ def generate_menu(data, season, sub_category_pref, outings, bmi_category):
57
 
58
  # Function to calculate BMI and recommend diet for adults
59
  def bmi_insights(weight, height_cm):
60
- # Convert height from cm to meters
61
  height_m = height_cm / 100
62
  bmi = weight / (height_m ** 2)
63
 
64
  if bmi < 18.5:
65
- return f"Your BMI is {bmi:.2f}. You are underweight. A diet rich in proteins and healthy fats would be beneficial. Consider incorporating more calories and nutritious snacks.", "Underweight"
66
  elif 18.5 <= bmi < 24.9:
67
- return f"Your BMI is {bmi:.2f}. You are in the normal weight range. Maintain a balanced diet, including fruits, vegetables, whole grains, and lean proteins.", "Normal Weight"
68
  elif 25 <= bmi < 29.9:
69
- return f"Your BMI is {bmi:.2f}. You are overweight. A diet with fewer carbs and more lean proteins can help manage your weight. Consider reducing sugar intake.", "Overweight"
70
  else:
71
- return f"Your BMI is {bmi:.2f}. You are obese. A calorie-restricted diet with a focus on whole foods, vegetables, and lean proteins is recommended. Consult a health professional for personalized guidance.", "Obese"
72
 
73
  # Function to provide general diet recommendation for infants
74
  def infant_diet_recommendation():
75
  return (
76
  "For infants (up to 12 months), breast milk or formula should be the primary source of nutrition. "
77
  "Around 6 months, you can start introducing solid foods, including pureed fruits, vegetables, and cereals. "
78
- "Ensure a variety of textures as they grow and introduce protein-rich foods, like pureed meat or lentils. "
79
  "Consult with your pediatrician for more personalized advice."
80
  )
81
 
@@ -108,6 +110,17 @@ def main():
108
  bmi_message, bmi_category = bmi_insights(weight, height_cm)
109
  st.sidebar.success(bmi_message)
110
 
 
 
 
 
 
 
 
 
 
 
 
111
  # Google Drive file URL
112
  file_url = 'https://drive.google.com/uc?id=1BJFao3C6p8k3_KjLfmDo5KbNMrTs7MRo' # Replace with actual file link
113
  data = load_data(file_url)
@@ -118,23 +131,8 @@ def main():
118
 
119
  outings = st.number_input("Enter the number of outings this week", min_value=0, max_value=14, value=0)
120
 
121
- st.header("How many dishes from each sub-category would you like?")
122
- sub_category_pref = {
123
- 'Sabzi': st.number_input("Number of Sabzi dishes", min_value=0, value=0),
124
- 'Rice': st.number_input("Number of Rice dishes", min_value=0, value=0),
125
- 'Daal': st.number_input("Number of Daal dishes", min_value=0, value=0),
126
- 'Meat': st.number_input("Number of Meat dishes", min_value=0, value=0),
127
- 'Chicken': st.number_input("Number of Chicken dishes", min_value=0, value=0),
128
- 'Fish': st.number_input("Number of Fish dishes", min_value=0, value=0)
129
- }
130
-
131
- total_main_courses = sum(sub_category_pref.values()) + outings
132
- if total_main_courses > 14:
133
- st.warning("The total number of main courses exceeds 14! Please adjust your preferences.")
134
- return
135
-
136
  if st.button("Generate Menu"):
137
- lunch_menu, dinner_menu, total_cost = generate_menu(data, season, sub_category_pref, outings, bmi_category)
138
 
139
  st.header("Weekly Menu")
140
  st.subheader("Lunch Menu")
 
10
  return pd.read_excel(file_path, engine='openpyxl')
11
 
12
  # Function to generate the weekly menu
13
+ def generate_menu(data, season, outings, bmi_category):
14
  # Filter season data
15
  season_data = data[(data['Season'] == season) | (data['Season'] == 'All Seasons')]
16
 
17
  # Adjust the menu based on BMI category
18
  if bmi_category == "Underweight":
19
  # Suggest high-calorie dishes like meat, rice, and calorie-dense vegetables
20
+ preferred_dishes = ['Meat', 'Rice', 'Sabzi', 'Chicken', 'Fish']
21
  elif bmi_category == "Normal Weight":
22
  # Balanced meals with a variety of dishes
23
+ preferred_dishes = ['Sabzi', 'Rice', 'Daal', 'Chicken', 'Fish', 'Meat']
24
  elif bmi_category == "Overweight":
25
  # Focus on lean proteins and vegetables, limiting carbs
26
+ preferred_dishes = ['Sabzi', 'Chicken', 'Fish', 'Lean Meat', 'Daal']
27
  else: # Obese category
28
  # Focus on lean proteins, vegetables, and smaller portions of carbs
29
+ preferred_dishes = ['Sabzi', 'Daal', 'Chicken', 'Fish', 'Vegetables']
30
 
31
  # Select dishes based on the BMI category and preferences
32
  menu = []
 
43
  side_dishes = data[data['Course'] == 'Side Dish'].sample(2).to_dict('records')
44
  menu.extend(side_dishes)
45
 
46
+ # Create DataFrame for the menu
47
  menu_df = pd.DataFrame(menu)
48
+
49
+ # Split the menu into lunch and dinner
50
  lunch_menu = menu_df.iloc[:len(menu_df)//2]
51
  dinner_menu = menu_df.iloc[len(menu_df)//2:]
52
 
53
+ # Calculate the total cost
54
  total_cost = menu_df["Cost per 4 persons"].sum()
55
 
56
+ # Only include the names of the dishes for lunch and dinner menus
57
  lunch_menu = lunch_menu[["Name"]]
58
  dinner_menu = dinner_menu[["Name"]]
59
 
 
61
 
62
  # Function to calculate BMI and recommend diet for adults
63
  def bmi_insights(weight, height_cm):
 
64
  height_m = height_cm / 100
65
  bmi = weight / (height_m ** 2)
66
 
67
  if bmi < 18.5:
68
+ return f"Your BMI is {bmi:.2f}. You are underweight. A diet rich in proteins and healthy fats would be beneficial.", "Underweight"
69
  elif 18.5 <= bmi < 24.9:
70
+ return f"Your BMI is {bmi:.2f}. You are in the normal weight range. Maintain a balanced diet.", "Normal Weight"
71
  elif 25 <= bmi < 29.9:
72
+ return f"Your BMI is {bmi:.2f}. You are overweight. A diet with fewer carbs and more lean proteins can help manage your weight.", "Overweight"
73
  else:
74
+ return f"Your BMI is {bmi:.2f}. You are obese. A calorie-restricted diet with a focus on whole foods and lean proteins is recommended.", "Obese"
75
 
76
  # Function to provide general diet recommendation for infants
77
  def infant_diet_recommendation():
78
  return (
79
  "For infants (up to 12 months), breast milk or formula should be the primary source of nutrition. "
80
  "Around 6 months, you can start introducing solid foods, including pureed fruits, vegetables, and cereals. "
 
81
  "Consult with your pediatrician for more personalized advice."
82
  )
83
 
 
110
  bmi_message, bmi_category = bmi_insights(weight, height_cm)
111
  st.sidebar.success(bmi_message)
112
 
113
+ # Dropdown for selecting medical condition(s)
114
+ medical_condition = st.sidebar.selectbox(
115
+ "Select any medical condition", [
116
+ "None", "Diabetes", "Celiac Disease", "Hypertension", "Heart Disease", "Obesity",
117
+ "Cholesterol Disorders", "IBS", "GERD", "Peptic Ulcers", "Gout", "Lactose Intolerance",
118
+ "Kidney Disease", "Hypothyroidism", "Anemia", "Food Allergies", "Acid Reflux",
119
+ "Crohn's Disease", "Osteoporosis", "Autoimmune Diseases", "Migraines", "PCOS",
120
+ "CFS", "Mental Health"
121
+ ]
122
+ )
123
+
124
  # Google Drive file URL
125
  file_url = 'https://drive.google.com/uc?id=1BJFao3C6p8k3_KjLfmDo5KbNMrTs7MRo' # Replace with actual file link
126
  data = load_data(file_url)
 
131
 
132
  outings = st.number_input("Enter the number of outings this week", min_value=0, max_value=14, value=0)
133
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
  if st.button("Generate Menu"):
135
+ lunch_menu, dinner_menu, total_cost = generate_menu(data, season, outings, bmi_category)
136
 
137
  st.header("Weekly Menu")
138
  st.subheader("Lunch Menu")