SanaAdeel commited on
Commit
6cabea8
·
verified ·
1 Parent(s): 02d6070

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -59
app.py CHANGED
@@ -10,26 +10,41 @@ 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):
 
14
  season_data = data[(data['Season'] == season) | (data['Season'] == 'All Seasons')]
15
-
16
- meals_needed = 14 - outings # Main Courses (14) minus outings
17
-
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  menu = []
19
- for sub_category, freq in sub_category_pref.items():
20
  sub_category_dishes = season_data[season_data['Sub-Category'] == sub_category]
21
- menu.extend(sub_category_dishes.sample(min(freq, len(sub_category_dishes))).to_dict('records'))
22
-
23
- menu = menu[:meals_needed]
24
 
 
 
25
  outing_dishes = data[data['Home Made / Outing'] == 'Outing'].sample(outings).to_dict('records')
26
  menu.extend(outing_dishes)
27
 
 
28
  side_dishes = data[data['Course'] == 'Side Dish'].sample(2).to_dict('records')
29
  menu.extend(side_dishes)
30
 
 
31
  menu_df = pd.DataFrame(menu)
32
-
33
  lunch_menu = menu_df.iloc[:len(menu_df)//2]
34
  dinner_menu = menu_df.iloc[len(menu_df)//2:]
35
 
@@ -42,55 +57,28 @@ def generate_menu(data, season, sub_category_pref, outings):
42
 
43
  # Function to calculate BMI and recommend diet for adults
44
  def bmi_insights(weight, height_cm):
 
45
  height_m = height_cm / 100
46
  bmi = weight / (height_m ** 2)
47
 
48
  if bmi < 18.5:
49
- return f"Your BMI is {bmi:.2f}. You are underweight. A diet rich in proteins and healthy fats would be beneficial."
50
  elif 18.5 <= bmi < 24.9:
51
- return f"Your BMI is {bmi:.2f}. You are in the normal weight range. Maintain a balanced diet."
52
  elif 25 <= bmi < 29.9:
53
- return f"Your BMI is {bmi:.2f}. You are overweight. A diet with fewer carbs and more lean proteins can help manage your weight."
54
  else:
55
- 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."
56
 
57
  # Function to provide general diet recommendation for infants
58
  def infant_diet_recommendation():
59
  return (
60
  "For infants (up to 12 months), breast milk or formula should be the primary source of nutrition. "
61
  "Around 6 months, you can start introducing solid foods, including pureed fruits, vegetables, and cereals. "
 
62
  "Consult with your pediatrician for more personalized advice."
63
  )
64
 
65
- # Function to provide dietary recommendations based on medical conditions
66
- def medical_condition_recommendation(condition):
67
- recommendations = {
68
- "Diabetes": "A low-carb diet is essential. Focus on fiber-rich vegetables, lean proteins, and healthy fats. Avoid sugary foods.",
69
- "Celiac Disease": "Avoid gluten-containing foods like wheat, barley, and rye. Focus on gluten-free grains, fruits, vegetables, and lean proteins.",
70
- "Hypertension": "Limit salt intake. Incorporate potassium-rich foods such as bananas, spinach, and potatoes. A heart-healthy diet with lean proteins is ideal.",
71
- "Heart Disease": "Consume a heart-healthy diet rich in omega-3 fatty acids, vegetables, and whole grains. Limit saturated fats and processed foods.",
72
- "Obesity": "Focus on a calorie-restricted diet, prioritizing vegetables, lean meats, and whole grains. Avoid sugary snacks and drinks.",
73
- "Cholesterol Disorders": "Eat foods rich in fiber, such as oats, fruits, and vegetables. Limit saturated fats and trans fats.",
74
- "IBS": "Incorporate fiber-rich foods like oats and vegetables. Avoid foods that cause bloating, such as beans, cabbage, and onions.",
75
- "GERD": "Avoid acidic and spicy foods, caffeine, and alcohol. Focus on bland, easy-to-digest meals like rice, oatmeal, and non-citrus fruits.",
76
- "Peptic Ulcers": "Avoid spicy, fatty, and acidic foods. Focus on bland foods like rice, oatmeal, and non-citrus fruits.",
77
- "Gout": "Limit foods high in purines, such as red meat, shellfish, and alcohol. Focus on low-fat dairy, fruits, and vegetables.",
78
- "Lactose Intolerance": "Avoid dairy products or choose lactose-free alternatives. Incorporate plant-based sources of calcium.",
79
- "Kidney Disease": "Reduce sodium, potassium, and phosphorus intake. Focus on lean proteins and avoid processed foods.",
80
- "Hypothyroidism": "Increase iodine-rich foods like seaweed, eggs, and dairy. Focus on vegetables and lean proteins.",
81
- "Anemia": "Focus on iron-rich foods such as red meat, spinach, and beans. Pair with vitamin C-rich foods for better absorption.",
82
- "Food Allergies": "Avoid allergenic foods like peanuts, tree nuts, dairy, eggs, shellfish, and others. Focus on a balanced, allergy-free diet.",
83
- "Acid Reflux": "Avoid acidic and spicy foods. Incorporate alkaline foods like bananas, melons, and oatmeal.",
84
- "Crohn's Disease": "Focus on low-fiber foods and avoid spicy, fatty, and acidic foods. Prioritize lean meats and easy-to-digest grains.",
85
- "Osteoporosis": "Ensure adequate calcium and vitamin D intake through dairy or fortified alternatives. Incorporate weight-bearing exercises.",
86
- "Autoimmune Diseases": "A diet rich in anti-inflammatory foods like leafy greens, berries, nuts, and fatty fish is ideal.",
87
- "Migraines": "Avoid foods that trigger migraines, such as chocolate, caffeine, and aged cheeses. Focus on magnesium-rich foods.",
88
- "PCOS": "Focus on a low-glycemic index diet with plenty of fruits, vegetables, and lean proteins. Limit processed sugars.",
89
- "CFS": "A balanced diet with adequate calories and nutrients is essential. Focus on anti-inflammatory foods and avoid refined sugars.",
90
- "Mental Health": "Focus on omega-3 fatty acids, whole grains, fruits, and vegetables. Avoid processed foods and sugar."
91
- }
92
- return recommendations.get(condition, "No specific recommendations available.")
93
-
94
  # Main workflow
95
  def main():
96
  st.title("Roz Roz Ka Masla..... Aaj Kya Pakayen!!! ")
@@ -117,24 +105,9 @@ def main():
117
  height_cm = st.sidebar.number_input("Enter your height (cm)", min_value=90, max_value=250, value=175)
118
 
119
  if st.sidebar.button("Get BMI Insights"):
120
- bmi_message = bmi_insights(weight, height_cm)
121
  st.sidebar.success(bmi_message)
122
 
123
- # Dropdown for selecting medical condition(s)
124
- medical_condition = st.sidebar.selectbox(
125
- "Select any medical condition", [
126
- "None", "Diabetes", "Celiac Disease", "Hypertension", "Heart Disease", "Obesity",
127
- "Cholesterol Disorders", "IBS", "GERD", "Peptic Ulcers", "Gout", "Lactose Intolerance",
128
- "Kidney Disease", "Hypothyroidism", "Anemia", "Food Allergies", "Acid Reflux",
129
- "Crohn's Disease", "Osteoporosis", "Autoimmune Diseases", "Migraines", "PCOS",
130
- "CFS", "Mental Health"
131
- ]
132
- )
133
-
134
- if medical_condition != "None":
135
- condition_recommendation = medical_condition_recommendation(medical_condition)
136
- st.sidebar.write(condition_recommendation)
137
-
138
  # Google Drive file URL
139
  file_url = 'https://drive.google.com/uc?id=1BJFao3C6p8k3_KjLfmDo5KbNMrTs7MRo' # Replace with actual file link
140
  data = load_data(file_url)
@@ -161,7 +134,7 @@ def main():
161
  return
162
 
163
  if st.button("Generate Menu"):
164
- lunch_menu, dinner_menu, total_cost = generate_menu(data, season, sub_category_pref, outings)
165
 
166
  st.header("Weekly Menu")
167
  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, 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 = []
33
+ for sub_category in preferred_dishes:
34
  sub_category_dishes = season_data[season_data['Sub-Category'] == sub_category]
35
+ menu.extend(sub_category_dishes.sample(min(3, len(sub_category_dishes))).to_dict('records'))
 
 
36
 
37
+ # Select outing dishes
38
+ meals_needed = 14 - outings
39
  outing_dishes = data[data['Home Made / Outing'] == 'Outing'].sample(outings).to_dict('records')
40
  menu.extend(outing_dishes)
41
 
42
+ # Select side dishes
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
 
 
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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
  # Main workflow
83
  def main():
84
  st.title("Roz Roz Ka Masla..... Aaj Kya Pakayen!!! ")
 
105
  height_cm = st.sidebar.number_input("Enter your height (cm)", min_value=90, max_value=250, value=175)
106
 
107
  if st.sidebar.button("Get BMI Insights"):
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)
 
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")