Initial commit

parents
# Default ignored files
/shelf/
/workspace.xml
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<orderEntry type="jdk" jdkName="Python 3.8 (food_recomend_mechinelearning)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="TestRunnerService">
<option name="PROJECT_TEST_RUNNER" value="pytest" />
</component>
</module>
\ No newline at end of file
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8 (food_recomend_mechinelearning)" project-jdk-type="Python SDK" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/food_recomend_mechinelearning.iml" filepath="$PROJECT_DIR$/.idea/food_recomend_mechinelearning.iml" />
</modules>
</component>
</project>
\ No newline at end of file
import os
import psutil
import time
import subprocess
import fnmatch
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
from tkinter import *
from PIL import ImageFilter,Image
from tkinter import filedialog, messagebox
from sklearn.cluster import KMeans
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestClassifier
data=pd.read_csv('normal_food.csv')
Breakfastdata=data['Breakfast']
BreakfastdataNumpy=Breakfastdata.to_numpy()
Lunchdata=data['Lunch']
LunchdataNumpy=Lunchdata.to_numpy()
Dinnerdata=data['Dinner']
DinnerdataNumpy=Dinnerdata.to_numpy()
Food_itemsdata=data['Food_items']
def show_entry_fields():
print("\n Age: %s\n Veg-NonVeg: %s\n Weight: %s kg\n Hight: %s cm\n" % (e1.get(), e2.get(),e3.get(), e4.get()))
def Weight_Loss():
show_entry_fields()
breakfastfoodseparated=[]
Lunchfoodseparated=[]
Dinnerfoodseparated=[]
breakfastfoodseparatedID=[]
LunchfoodseparatedID=[]
DinnerfoodseparatedID=[]
for i in range(len(Breakfastdata)):
if BreakfastdataNumpy[i]==1:
breakfastfoodseparated.append( Food_itemsdata[i] )
breakfastfoodseparatedID.append(i)
if LunchdataNumpy[i]==1:
Lunchfoodseparated.append(Food_itemsdata[i])
LunchfoodseparatedID.append(i)
if DinnerdataNumpy[i]==1:
Dinnerfoodseparated.append(Food_itemsdata[i])
DinnerfoodseparatedID.append(i)
# retrieving Lunch data rows by loc method |
LunchfoodseparatedIDdata = data.iloc[LunchfoodseparatedID]
LunchfoodseparatedIDdata=LunchfoodseparatedIDdata.T
#print(LunchfoodseparatedIDdata)
val=list(np.arange(5,15))
Valapnd=[0]+val
LunchfoodseparatedIDdata=LunchfoodseparatedIDdata.iloc[Valapnd]
LunchfoodseparatedIDdata=LunchfoodseparatedIDdata.T
#print(LunchfoodseparatedIDdata)
# retrieving Breafast data rows by loc method
breakfastfoodseparatedIDdata = data.iloc[breakfastfoodseparatedID]
breakfastfoodseparatedIDdata=breakfastfoodseparatedIDdata.T
val=list(np.arange(5,15))
Valapnd=[0]+val
breakfastfoodseparatedIDdata=breakfastfoodseparatedIDdata.iloc[Valapnd]
breakfastfoodseparatedIDdata=breakfastfoodseparatedIDdata.T
# retrieving Dinner Data rows by loc method
DinnerfoodseparatedIDdata = data.iloc[DinnerfoodseparatedID]
DinnerfoodseparatedIDdata=DinnerfoodseparatedIDdata.T
val=list(np.arange(5,15))
Valapnd=[0]+val
DinnerfoodseparatedIDdata=DinnerfoodseparatedIDdata.iloc[Valapnd]
DinnerfoodseparatedIDdata=DinnerfoodseparatedIDdata.T
#calculating BMI
age=int(e1.get())
veg=float(e2.get())
weight=float(e3.get())
height=float(e4.get())
bmi = weight/((height/100)**2)
agewiseinp=0
for lp in range (0,80,20):
test_list=np.arange(lp,lp+20)
for i in test_list:
if(i == age):
tr=round(lp/20)
agecl=round(lp/20)
#conditions
print("Your body mass index is: ", bmi)
if ( bmi < 16):
print("Acoording to your BMI, you are Severely Underweight")
clbmi=4
elif ( bmi >= 16 and bmi < 18.5):
print("Acoording to your BMI, you are Underweight")
clbmi=3
elif ( bmi >= 18.5 and bmi < 25):
print("Acoording to your BMI, you are Healthy")
clbmi=2
elif ( bmi >= 25 and bmi < 30):
print("Acoording to your BMI, you are Overweight")
clbmi=1
elif ( bmi >=30):
print("Acoording to your BMI, you are Severely Overweight")
clbmi=0
#converting into numpy array
DinnerfoodseparatedIDdata=DinnerfoodseparatedIDdata.to_numpy()
LunchfoodseparatedIDdata=LunchfoodseparatedIDdata.to_numpy()
breakfastfoodseparatedIDdata=breakfastfoodseparatedIDdata.to_numpy()
ti=(clbmi+agecl)/2
## K-Means Based Dinner Food
Datacalorie=DinnerfoodseparatedIDdata[1:,1:len(DinnerfoodseparatedIDdata)]
X = np.array(Datacalorie)
kmeans = KMeans(n_clusters=3, random_state=0).fit(X)
XValu=np.arange(0,len(kmeans.labels_))
# retrieving the labels for dinner food
dnrlbl=kmeans.labels_
## K-Means Based lunch Food
Datacalorie=LunchfoodseparatedIDdata[1:,1:len(LunchfoodseparatedIDdata)]
X = np.array(Datacalorie)
kmeans = KMeans(n_clusters=3, random_state=0).fit(X)
XValu=np.arange(0,len(kmeans.labels_))
# retrieving the labels for lunch food
lnchlbl=kmeans.labels_
## K-Means Based lunch Food
Datacalorie=breakfastfoodseparatedIDdata[1:,1:len(breakfastfoodseparatedIDdata)]
X = np.array(Datacalorie)
kmeans = KMeans(n_clusters=3, random_state=0).fit(X)
XValu=np.arange(0,len(kmeans.labels_))
# retrieving the labels for breakfast food
brklbl=kmeans.labels_
inp=[]
## Reading of the Dataet
datafin=pd.read_csv('nutrition_container.csv')
## train set
dataTog=datafin.T
bmicls=[0,1,2,3,4]
agecls=[0,1,2,3,4]
weightlosscat = dataTog.iloc[[1,2,7,8]]
weightlosscat=weightlosscat.T
weightgaincat= dataTog.iloc[[0,1,2,3,4,7,9,10]]
weightgaincat=weightgaincat.T
healthycat = dataTog.iloc[[1,2,3,4,6,7,9]]
healthycat=healthycat.T
weightlosscatDdata=weightlosscat.to_numpy()
weightgaincatDdata=weightgaincat.to_numpy()
healthycatDdata=healthycat.to_numpy()
weightlosscat=weightlosscatDdata[1:,0:len(weightlosscatDdata)]
weightgaincat=weightgaincatDdata[1:,0:len(weightgaincatDdata)]
healthycat=healthycatDdata[1:,0:len(healthycatDdata)]
weightlossfin=np.zeros((len(weightlosscat)*5,6),dtype=np.float32)
weightgainfin=np.zeros((len(weightgaincat)*5,10),dtype=np.float32)
healthycatfin=np.zeros((len(healthycat)*5,9),dtype=np.float32)
t=0
r=0
s=0
yt=[]
yr=[]
ys=[]
for zz in range(5):
for jj in range(len(weightlosscat)):
valloc=list(weightlosscat[jj])
valloc.append(bmicls[zz])
valloc.append(agecls[zz])
weightlossfin[t]=np.array(valloc)
yt.append(brklbl[jj])
t+=1
for jj in range(len(weightgaincat)):
valloc=list(weightgaincat[jj])
valloc.append(bmicls[zz])
valloc.append(agecls[zz])
weightgainfin[r]=np.array(valloc)
yr.append(lnchlbl[jj])
r+=1
for jj in range(len(healthycat)):
valloc=list(healthycat[jj])
valloc.append(bmicls[zz])
valloc.append(agecls[zz])
healthycatfin[s]=np.array(valloc)
ys.append(dnrlbl[jj])
s+=1
X_test=np.zeros((len(weightlosscat),6),dtype=np.float32)
print('####################')
#randomforest
for jj in range(len(weightlosscat)):
valloc=list(weightlosscat[jj])
valloc.append(agecl)
valloc.append(clbmi)
X_test[jj]=np.array(valloc)*ti
X_train=weightlossfin# Features
y_train=yt # Labels
#Create a Gaussian Classifier
clf=RandomForestClassifier(n_estimators=100)
#Train the model using the training sets y_pred=clf.predict(X_test)
clf.fit(X_train,y_train)
#print (X_test[1])
X_test2=X_test
y_pred=clf.predict(X_test)
print ('SUGGESTED FOOD ::')
for ii in range(len(y_pred)):
if y_pred[ii]==2: #weightloss
print (Food_itemsdata[ii])
findata=Food_itemsdata[ii]
if int(veg)==1:
datanv=['Chicken Burger']
for it in range(len(datanv)):
if findata==datanv[it]:
print('VegNovVeg')
print('\n Thank You for taking our recommendations. :)')
def Weight_Gain():
show_entry_fields()
breakfastfoodseparated=[]
Lunchfoodseparated=[]
Dinnerfoodseparated=[]
breakfastfoodseparatedID=[]
LunchfoodseparatedID=[]
DinnerfoodseparatedID=[]
for i in range(len(Breakfastdata)):
if BreakfastdataNumpy[i]==1:
breakfastfoodseparated.append( Food_itemsdata[i] )
breakfastfoodseparatedID.append(i)
if LunchdataNumpy[i]==1:
Lunchfoodseparated.append(Food_itemsdata[i])
LunchfoodseparatedID.append(i)
if DinnerdataNumpy[i]==1:
Dinnerfoodseparated.append(Food_itemsdata[i])
DinnerfoodseparatedID.append(i)
# retrieving rows by loc method |
LunchfoodseparatedIDdata = data.iloc[LunchfoodseparatedID]
LunchfoodseparatedIDdata=LunchfoodseparatedIDdata.T
val=list(np.arange(5,15))
Valapnd=[0]+val
LunchfoodseparatedIDdata=LunchfoodseparatedIDdata.iloc[Valapnd]
LunchfoodseparatedIDdata=LunchfoodseparatedIDdata.T
# retrieving rows by loc method
breakfastfoodseparatedIDdata = data.iloc[breakfastfoodseparatedID]
breakfastfoodseparatedIDdata=breakfastfoodseparatedIDdata.T
val=list(np.arange(5,15))
Valapnd=[0]+val
breakfastfoodseparatedIDdata=breakfastfoodseparatedIDdata.iloc[Valapnd]
breakfastfoodseparatedIDdata=breakfastfoodseparatedIDdata.T
# retrieving rows by loc method
DinnerfoodseparatedIDdata = data.iloc[DinnerfoodseparatedID]
DinnerfoodseparatedIDdata=DinnerfoodseparatedIDdata.T
val=list(np.arange(5,15))
Valapnd=[0]+val
DinnerfoodseparatedIDdata=DinnerfoodseparatedIDdata.iloc[Valapnd]
DinnerfoodseparatedIDdata=DinnerfoodseparatedIDdata.T
#claculating BMI
age=int(e1.get())
veg=float(e2.get())
weight=float(e3.get())
height=float(e4.get())
bmi = weight/((height/100)**2)
for lp in range (0,80,20):
test_list=np.arange(lp,lp+20)
for i in test_list:
if(i == age):
tr=round(lp/20)
agecl=round(lp/20)
print("Your body mass index is: ", bmi)
if ( bmi < 16):
print("Acoording to your BMI, you are Severely Underweight")
clbmi=4
elif ( bmi >= 16 and bmi < 18.5):
print("Acoording to your BMI, you are Underweight")
clbmi=3
elif ( bmi >= 18.5 and bmi < 25):
print("Acoording to your BMI, you are Healthy")
clbmi=2
elif ( bmi >= 25 and bmi < 30):
print("Acoording to your BMI, you are Overweight")
clbmi=1
elif ( bmi >=30):
print("Acoording to your BMI, you are Severely Overweight")
clbmi=0
DinnerfoodseparatedIDdata=DinnerfoodseparatedIDdata.to_numpy()
LunchfoodseparatedIDdata=LunchfoodseparatedIDdata.to_numpy()
breakfastfoodseparatedIDdata=breakfastfoodseparatedIDdata.to_numpy()
ti=(bmi+agecl)/2
## K-Means Based Dinner Food
Datacalorie=DinnerfoodseparatedIDdata[1:,1:len(DinnerfoodseparatedIDdata)]
X = np.array(Datacalorie)
kmeans = KMeans(n_clusters=3, random_state=0).fit(X)
XValu=np.arange(0,len(kmeans.labels_))
# plt.bar(XValu,kmeans.labels_)
dnrlbl=kmeans.labels_
# plt.title("Predicted Low-High Weigted Calorie Foods")
## K-Means Based lunch Food
Datacalorie=LunchfoodseparatedIDdata[1:,1:len(LunchfoodseparatedIDdata)]
X = np.array(Datacalorie)
kmeans = KMeans(n_clusters=3, random_state=0).fit(X)
XValu=np.arange(0,len(kmeans.labels_))
# fig,axs=plt.subplots(1,1,figsize=(15,5))
# plt.bar(XValu,kmeans.labels_)
lnchlbl=kmeans.labels_
# plt.title("Predicted Low-High Weigted Calorie Foods")
## K-Means Based lunch Food
Datacalorie=breakfastfoodseparatedIDdata[1:,1:len(breakfastfoodseparatedIDdata)]
X = np.array(Datacalorie)
kmeans = KMeans(n_clusters=3, random_state=0).fit(X)
XValu=np.arange(0,len(kmeans.labels_))
# fig,axs=plt.subplots(1,1,figsize=(15,5))
# plt.bar(XValu,kmeans.labels_)
brklbl=kmeans.labels_
# plt.title("Predicted Low-High Weigted Calorie Foods")
inp=[]
## Reading of the Dataet
datafin=pd.read_csv('nutrition_container.csv')
datafin.head(5)
dataTog=datafin.T
bmicls=[0,1,2,3,4]
agecls=[0,1,2,3,4]
weightlosscat = dataTog.iloc[[1,2,7,8]]
weightlosscat=weightlosscat.T
weightgaincat= dataTog.iloc[[0,1,2,3,4,7,9,10]]
weightgaincat=weightgaincat.T
healthycat = dataTog.iloc[[1,2,3,4,6,7,9]]
healthycat=healthycat.T
weightlosscatDdata=weightlosscat.to_numpy()
weightgaincatDdata=weightgaincat.to_numpy()
healthycatDdata=healthycat.to_numpy()
weightlosscat=weightlosscatDdata[1:,0:len(weightlosscatDdata)]
weightgaincat=weightgaincatDdata[1:,0:len(weightgaincatDdata)]
healthycat=healthycatDdata[1:,0:len(healthycatDdata)]
weightlossfin=np.zeros((len(weightlosscat)*5,6),dtype=np.float32)
weightgainfin=np.zeros((len(weightgaincat)*5,10),dtype=np.float32)
healthycatfin=np.zeros((len(healthycat)*5,9),dtype=np.float32)
t=0
r=0
s=0
yt=[]
yr=[]
ys=[]
for zz in range(5):
for jj in range(len(weightlosscat)):
valloc=list(weightlosscat[jj])
valloc.append(bmicls[zz])
valloc.append(agecls[zz])
weightlossfin[t]=np.array(valloc)
yt.append(brklbl[jj])
t+=1
for jj in range(len(weightgaincat)):
valloc=list(weightgaincat[jj])
#print (valloc)
valloc.append(bmicls[zz])
valloc.append(agecls[zz])
weightgainfin[r]=np.array(valloc)
yr.append(lnchlbl[jj])
r+=1
for jj in range(len(healthycat)):
valloc=list(healthycat[jj])
valloc.append(bmicls[zz])
valloc.append(agecls[zz])
healthycatfin[s]=np.array(valloc)
ys.append(dnrlbl[jj])
s+=1
X_test=np.zeros((len(weightgaincat),10),dtype=np.float32)
print('####################')
# In[287]:
for jj in range(len(weightgaincat)):
valloc=list(weightgaincat[jj])
valloc.append(agecl)
valloc.append(clbmi)
X_test[jj]=np.array(valloc)*ti
X_train=weightgainfin# Features
y_train=yr # Labels
#Create a Gaussian Classifier
clf=RandomForestClassifier(n_estimators=100)
#Train the model using the training sets y_pred=clf.predict(X_test)
clf.fit(X_train,y_train)
X_test2=X_test
y_pred=clf.predict(X_test)
print ('SUGGESTED FOOD ITEMS ::')
for ii in range(len(y_pred)):
if y_pred[ii]==2:
print (Food_itemsdata[ii])
findata=Food_itemsdata[ii]
if int(veg)==1:
datanv=['Chicken Burger']
for it in range(len(datanv)):
if findata==datanv[it]:
print('VegNovVeg')
print('\n Thank You for taking our recommendations. :)')
def Healthy():
show_entry_fields()
breakfastfoodseparated=[]
Lunchfoodseparated=[]
Dinnerfoodseparated=[]
breakfastfoodseparatedID=[]
LunchfoodseparatedID=[]
DinnerfoodseparatedID=[]
for i in range(len(Breakfastdata)):
if BreakfastdataNumpy[i]==1:
breakfastfoodseparated.append( Food_itemsdata[i] )
breakfastfoodseparatedID.append(i)
if LunchdataNumpy[i]==1:
Lunchfoodseparated.append(Food_itemsdata[i])
LunchfoodseparatedID.append(i)
if DinnerdataNumpy[i]==1:
Dinnerfoodseparated.append(Food_itemsdata[i])
DinnerfoodseparatedID.append(i)
# retrieving rows by loc method |
LunchfoodseparatedIDdata = data.iloc[LunchfoodseparatedID]
LunchfoodseparatedIDdata=LunchfoodseparatedIDdata.T
val=list(np.arange(5,15))
Valapnd=[0]+val
LunchfoodseparatedIDdata=LunchfoodseparatedIDdata.iloc[Valapnd]
LunchfoodseparatedIDdata=LunchfoodseparatedIDdata.T
# retrieving rows by loc method
breakfastfoodseparatedIDdata = data.iloc[breakfastfoodseparatedID]
breakfastfoodseparatedIDdata=breakfastfoodseparatedIDdata.T
val=list(np.arange(5,15))
Valapnd=[0]+val
breakfastfoodseparatedIDdata=breakfastfoodseparatedIDdata.iloc[Valapnd]
breakfastfoodseparatedIDdata=breakfastfoodseparatedIDdata.T
# retrieving rows by loc method
DinnerfoodseparatedIDdata = data.iloc[DinnerfoodseparatedID]
DinnerfoodseparatedIDdata=DinnerfoodseparatedIDdata.T
val=list(np.arange(5,15))
Valapnd=[0]+val
DinnerfoodseparatedIDdata=DinnerfoodseparatedIDdata.iloc[Valapnd]
DinnerfoodseparatedIDdata=DinnerfoodseparatedIDdata.T
age=int(e1.get())
veg=float(e2.get())
weight=float(e3.get())
height=float(e4.get())
bmi = weight/((height/100)**2)
agewiseinp=0
for lp in range (0,80,20):
test_list=np.arange(lp,lp+20)
for i in test_list:
if(i == age):
tr=round(lp/20)
agecl=round(lp/20)
#conditions
print("Your body mass index is: ", bmi)
if ( bmi < 16):
print("Acoording to your BMI, you are Severely Underweight")
clbmi=4
elif ( bmi >= 16 and bmi < 18.5):
print("Acoording to your BMI, you are Underweight")
clbmi=3
elif ( bmi >= 18.5 and bmi < 25):
print("Acoording to your BMI, you are Healthy")
clbmi=2
elif ( bmi >= 25 and bmi < 30):
print("Acoording to your BMI, you are Overweight")
clbmi=1
elif ( bmi >=30):
print("Acoording to your BMI, you are Severely Overweight")
clbmi=0
DinnerfoodseparatedIDdata=DinnerfoodseparatedIDdata.to_numpy()
LunchfoodseparatedIDdata=LunchfoodseparatedIDdata.to_numpy()
breakfastfoodseparatedIDdata=breakfastfoodseparatedIDdata.to_numpy()
ti=(bmi+agecl)/2
Datacalorie=DinnerfoodseparatedIDdata[1:,1:len(DinnerfoodseparatedIDdata)]
X = np.array(Datacalorie)
kmeans = KMeans(n_clusters=3, random_state=0).fit(X)
XValu=np.arange(0,len(kmeans.labels_))
# fig,axs=plt.subplots(1,1,figsize=(15,5))
# plt.bar(XValu,kmeans.labels_)
dnrlbl=kmeans.labels_
# plt.title("Predicted Low-High Weigted Calorie Foods")
Datacalorie=LunchfoodseparatedIDdata[1:,1:len(LunchfoodseparatedIDdata)]
X = np.array(Datacalorie)
kmeans = KMeans(n_clusters=3, random_state=0).fit(X)
#print ('## Prediction Result ##')
#print(kmeans.labels_)
XValu=np.arange(0,len(kmeans.labels_))
# fig,axs=plt.subplots(1,1,figsize=(15,5))
# plt.bar(XValu,kmeans.labels_)
lnchlbl=kmeans.labels_
# plt.title("Predicted Low-High Weigted Calorie Foods")
Datacalorie=breakfastfoodseparatedIDdata[1:,1:len(breakfastfoodseparatedIDdata)]
X = np.array(Datacalorie)
kmeans = KMeans(n_clusters=3, random_state=0).fit(X)
XValu=np.arange(0,len(kmeans.labels_))
# fig,axs=plt.subplots(1,1,figsize=(15,5))
# plt.bar(XValu,kmeans.labels_)
brklbl=kmeans.labels_
# print (len(brklbl))
# plt.title("Predicted Low-High Weigted Calorie Foods")
inp=[]
## Reading of the Dataet
datafin=pd.read_csv('nutrition_container.csv')
datafin.head(5)
dataTog=datafin.T
bmicls=[0,1,2,3,4]
agecls=[0,1,2,3,4]
weightlosscat = dataTog.iloc[[1,2,7,8]]
weightlosscat=weightlosscat.T
weightgaincat= dataTog.iloc[[0,1,2,3,4,7,9,10]]
weightgaincat=weightgaincat.T
healthycat = dataTog.iloc[[1,2,3,4,6,7,9]]
healthycat=healthycat.T
weightlosscatDdata=weightlosscat.to_numpy()
weightgaincatDdata=weightgaincat.to_numpy()
healthycatDdata=healthycat.to_numpy()
weightlosscat=weightlosscatDdata[1:,0:len(weightlosscatDdata)]
weightgaincat=weightgaincatDdata[1:,0:len(weightgaincatDdata)]
healthycat=healthycatDdata[1:,0:len(healthycatDdata)]
weightlossfin=np.zeros((len(weightlosscat)*5,6),dtype=np.float32)
weightgainfin=np.zeros((len(weightgaincat)*5,10),dtype=np.float32)
healthycatfin=np.zeros((len(healthycat)*5,9),dtype=np.float32)
t=0
r=0
s=0
yt=[]
yr=[]
ys=[]
for zz in range(5):
for jj in range(len(weightlosscat)):
valloc=list(weightlosscat[jj])
valloc.append(bmicls[zz])
valloc.append(agecls[zz])
weightlossfin[t]=np.array(valloc)
yt.append(brklbl[jj])
t+=1
for jj in range(len(weightgaincat)):
valloc=list(weightgaincat[jj])
#print (valloc)
valloc.append(bmicls[zz])
valloc.append(agecls[zz])
weightgainfin[r]=np.array(valloc)
yr.append(lnchlbl[jj])
r+=1
for jj in range(len(healthycat)):
valloc=list(healthycat[jj])
valloc.append(bmicls[zz])
valloc.append(agecls[zz])
healthycatfin[s]=np.array(valloc)
ys.append(dnrlbl[jj])
s+=1
X_test=np.zeros((len(healthycat)*5,9),dtype=np.float32)
for jj in range(len(healthycat)):
valloc=list(healthycat[jj])
valloc.append(agecl)
valloc.append(clbmi)
X_test[jj]=np.array(valloc)*ti
X_train=healthycatfin# Features
y_train=ys # Labels
#Create a Gaussian Classifier
clf=RandomForestClassifier(n_estimators=100)
#Train the model using the training sets y_pred=clf.predict(X_test)
clf.fit(X_train,y_train)
X_test2=X_test
y_pred=clf.predict(X_test)
print ('SUGGESTED FOOD ITEMS ::')
for ii in range(len(y_pred)):
if y_pred[ii]==2:
print (Food_itemsdata[ii])
findata=Food_itemsdata[ii]
if int(veg)==1:
datanv=['Chicken Burger']
print('\n Thank You for taking our recommendations. :)')
if __name__ == '__main__':
main_win = Tk()
Label(main_win,text="Age").grid(row=0,column=0,sticky=W,pady=4)
Label(main_win,text="veg/Non veg (1/0)").grid(row=1,column=0,sticky=W,pady=4)
Label(main_win,text="Weight (in kg)").grid(row=2,column=0,sticky=W,pady=4)
Label(main_win,text="Height (in cm)").grid(row=3,column=0,sticky=W,pady=4)
e1 = Entry(main_win)
e2 = Entry(main_win)
e3 = Entry(main_win)
e4 = Entry(main_win)
e1.grid(row=0, column=1)
e2.grid(row=1, column=1)
e3.grid(row=2, column=1)
e4.grid(row=3, column=1)
Button(main_win,text='clear',command=main_win.quit).grid(row=5,column=0,sticky=W,pady=4)
Button(main_win,text='Weight Loss',command=Weight_Loss).grid(row=1,column=4,sticky=W,pady=4)
Button(main_win,text='Weight Gain',command=Weight_Gain).grid(row=2,column=4,sticky=W,pady=4)
Button(main_win,text='Healthy',command=Healthy).grid(row=3,column=4,sticky=W,pady=4)
main_win.geometry("400x200")
main_win.wm_title("mechinelearning food recomender")
main_win.mainloop()
Food_items,Breakfast,Lunch,Dinner,VegNovVeg,Calories,Fats,Proteins,Iron,Calcium,Sodium,Potassium,Carbohydrates,Fibre,VitaminD,Sugars
Asparagus Cooked,0,1,1, ,22,0.2,2.4,0.91,23,14,224,4.1,2,0,1.3
Avocados,1,0,0,0,160,15,2,0.55,12,7,485,8.5,6.7,0,0.7
Bananas,1,0,0,0,89,0.3,1.1,0.26,5,1,358,23,2.6,0,12
Bagels made in wheat,0,1,1,0,250,1.5,10,2.76,20,439,165,49,4.1,0,6.1
Berries,1,0,0,0,349,0.4,14,6.8,190,298,77,77,13,0,46
Brocolli,0,1,1,0,25,0.5,3.8,1.27,118,56,343,3.1,2.8,0,0.6
Brown Rice,0,1,1,0,362,2.7,7.5,1.8,33,4,268,76,3.4,0,0
Cauliflower,0,1,1,0,32,0.3,3,0.72,32,259,278,6.3,3.3,0,0
American cheese,1,0,0,0,331,24,20,0.84,497,966,363,8.3,0,0,0
Coffee,1,0,0,0,2,0,0.3,0.02,2,1,50,0.2,0,0,0
Corn,1,1,1,0,97,1.4,3.3,0.55,2,253,3.3,22,2.7,0,7.7
Dark chocolates,0,0,1,0,556,32,5.5,2.13,30,6,502,60,6.5,0,48
Grapes,1,0,0,0,93,2.1,5.6,2.63,363,9,272,17,11,0,6.3
Milk,1,0,1,0,97,6.9,3.8,0.12,169,52,178,5.2,0,0,0
Cashew Nuts,1,0,0,0,553,44,18,6.68,37,12,660,30,3.3,0,5.9
Onions,0,1,1,0,40,0.1,1.1,0.21,23,4,146,9.3,1.7,0,4.2
Orange,1,0,0,0,97,0.2,1.5,0.8,161,3,212,25,11,0,0
Pasta canned with tomato sauce,0,1,1,0,71,0.7,2.2,0.91,13,381,192,14,0.9,0,4
Pears,1,0,0,0,57,0.1,0.4,0.18,9,1,116,15,3.1,0,9.8
Peas,0,1,1,0,81,0.4,5.4,1.47,25,5,244,14,5.7,0,5.7
Protein Powder,1,0,0,0,411,17,46,8.57,500,329,1129,19,7.1,200,5.7
Pumpkin,0,1,1,0,18,0.1,0.7,0.57,15,237,230,4.3,1.1,0,2.1
Tuna Salad,0,1,1,1,187,9.3,16,1,17,402,178,9.4,0,0,0
Tuna Fish,0,0,1,1,184,6.3,30,1.31,10,50,323,0,0,0,0
Peproni Pizza,0,0,1,0,298,14,12,2.14,146,692,199,30,1.8,0,3.2
Cheese Pizza,0,0,1,0,276,11,11,2.47,192,580,170,33,2.1,0,2.5
French Fries,0,1,1,0,289,14,3.5,0.91,17,357,545,37,3.9,0,0.3
Chicken Burger,0,1,1,1,292,15,18,0.62,13,859,315,20,1.3,0,0
Cheese Burger,0,1,1,0,256,12,13,2.78,92,660,178,25,1.4,0,0
Chicken Sandwich,0,1,1,1,257,12,15,1.32,92,605,256,23,1.2,0,5
Sugar Doughnuts,0,1,1,0,426,23,5.2,1.06,60,402,102,51,1.5,0,32
Chocolate Doughnuts,0,1,1,0,452,25,4.9,4,24,326,201,51,1.9,0,27
Pop Corn - Caramel,1,0,1,0,381,1.4,2,0.8,18,286,110,90,2.5,0,65
Pop Corn,1,0,1,0,429,9.5,13,2.28,11,490,241,73,14,0,0.5
Dosa,1,1,1,0,168,3.7,4.5,8,0.7,94,76,29,0.9,0,0.1
Idli,1,1,1,0,156,1.7,5,17.2,4,207,63,30.2,2.1,0,0.74
Poha,1,0,0,0,130,1.5,2.6,3.16,1,201,117,26.9,1.1,0,0.5
Chappati,0,1,1,0,297,7.5,11,3.01,93,409,266,46,4.9,0,2.7
Tomato,1,1,1,0,16,0.2,1.2,0.47,5,42,212,3.2,0.9,0,2.63
Yogurt,1,1,1,0,60,4,3.1,0.08,183,70,234,7,0,1,7
Brownie,1,0,0,0,407,6.2,4.4,3.81,17,457,51,84,2.9,0,55
Noodles,0,1,1,0,108,0.2,1.8,0.14,4,19,4,24,1,0,0
Uttapam,1,1,1,0,188,7.2,4.4,24,6.4,522,91,26.4,2.2,0,0.24
Bhaji Pav,1,0,0,0,151,2.4,9,37.4,3.4,438,180,29.3,1,0,1.35
Dal Makhani,0,1,1,0,109,8.5,2.1,35.2,8.3,243,366,6.3,1.5,0,3.29
Almonds,1,0,0,0,579,50,21,3.71,269,1,733,22,13,0,4.4
Mushrooms,1,1,1,0,22,0.3,3.1,0.5,3,5,318,3.3,1,7,2
Egg Yolk cooked,1,0,0,1,196,15,14,1.89,62,207,152,0.8,0,88,0.4
Sweet Potatoes cooked,1,1,0,0,76,0.1,1.4,0.72,27,27,230,18,2.5,0,5.7
Boiled Potatoes,1,1,1,0,87,0.1,1.9,0.31,5,240,379,20,2,0,0.9
White Rice,0,1,1,0,360,0.6,6.6,4.36,9,1,86,79,1.4,0,0
Orange juice,1,0,0,0,45,0.2,0.7,0.2,11,1,200,10,0.2,0,8.4
Greek yogurt plain,1,1,1,0,73,1.9,10,0.04,115,34,141,3.9,0,0,3.6
Oat Bran Cooked,1,0,0,0,40,0.9,3.2,0.88,10,1,92,11,2.6,0,0
Green Tea,1,0,0,0,1,0,0.2,0.02,0,1,0.2,0,0,0,0
Chia seeds,1,0,0,0,486,31,17,7.72,631,16,407,42,34,0,0
Cottage cheese with vegetables,0,1,1,0,95,4.2,11,0.1,56,403,86,3,0.1,0,0.4
Salmon,0,1,1,1,127,4.4,21,0.38,7,75,366,0,0,435,0
Cereals-Corn Flakes,1,0,0,0,384,0.9,5.9,19.4,2,571,107,88,2.7,286,7.8
Beans,0,1,1,0,31,0.2,1.8,1.03,37,6,211,7,2.7,0,3.3
Lentils,0,1,1,0,101,0.5,8.8,3.1,14,246,284,21,0,0,0
Pasta with corn homemade,0,1,1,0,126,0.7,2.6,0.25,1,0,31,28,4.8,0,0
Tea,1,0,0,0,1,0,0,0.08,2,1,9,0.2,0,0,0
Apples,1,0,0,0,52,0.2,0.3,0.12,6,1,107,14,24,0,10
Strawberries,1,0,0,0,32,0.3,0.7,0.41,16,1,153,7.7,2,0,4.9
Quninoa,1,1,0,0,120,1.9,4.4,1.49,17,7,172,21,2.8,0,0.9
Goat meat,0,1,1,1,109,2.3,21,2.83,13,82,385,57,0,0,0
Rabbit meat,0,1,1,1,114,2.3,22,3.2,12,50,378,0,0,0,0
Chicken Strips,0,0,1,1,295,15,19,0.72,11,798,334,22,1.1,0,0.3
Steak Fries,0,1,1,1,255,13,3.3,0.69,19,43,551,31,3.5,0,0.9
Mexican Rice,0,1,1,0,195,4.9,3.6,1.18,39,677,131,34,1.1,0,1.4
Fried Shrimp,0,0,1,1,319,20,14,1.54,47,1400,128,21,1.5,0,0.8
Spaghetti and meatballs,0,0,1,1,170,8.5,7.8,1.29,45,351,206,16,1.5,0,2
Macroni n Cheese ,0,1,1,0,194,12,6.5,57,145,375,127,16,1.1,0,2.8
Pork cooked,0,0,1,1,297,21,26,1.29,22,73,362,0,0,0,0
Bacon cooked,0,0,1,1,146,2.8,28,0.56,7,993,999,1.8,0,0,1.2
Nachos,1,1,1,0,350,22,4.3,0.75,63,313,362,35,3.2,0,2.2
Chicken Popcorn,0,1,1,1,351,22,18,1.42,32,1140,288,21,1,0,0
Turkey cooked,0,1,1,1,203,10,27,1.52,28,78,294,0,0,8,0
Oyster cooked,0,1,1,1,159,4,29,4.9,6,81,409,0,0,0,0
Beef sticks,1,0,0,1,550,50,22,3.4,68,1531,257,5.4,0,0,0
Banana Chips,1,0,0,0,519,34,2.3,1.25,18,6,536,58,7.7,0,35
Honey,1,0,1,0,304,0,0.3,0.42,6,4,52,82,0.2,0,82
Chocolate Icecream,0,0,1,0,216,11,3.8,0.93,109,76,249,28,1.2,0,25
Vanilla Ice cream,0,0,1,0,207,11,3.5,0.09,128,80,199,24,0.7,0,21
Strawberry Icecream,0,0,1,0,192,8.4,3.2,0.21,120,60,188,28,0.9,0,0
Marshmallows,0,0,1,0,318,0.2,1.8,0.23,3,80,5,81,0.1,0,58
Chocolate milk,1,0,0,0,535,30,7.7,2.35,189,79,372,59,3.4,0,52
Rice Pudding,0,0,1,0,376,0.1,2.7,1.79,14,366,5,91,0.7,0,0
0Calories ,1Fats (gm),2Proteins(g),3Iron(mg),4Calcium(mg),5Sodium(mg),6Potassium(mg),7Carbohydrates (gm),8Fibre (gm),9Vitamin D (mcg),10Sugars (gm)
160,15,2,0.55,12,7,485,8.5,6.7,0,0.7
89,0.3,1.1,0.26,5,1,358,8.5,2.6,0,12
349,0.4,14,6.8,190,298,77,8.5,13,0,46
331,24,20,0.84,497,966,363,8.5,0,0,0
2,0,0.3,0.02,2,1,50,8.5,0,0,0
97,1.4,3.3,0.55,2,253,3.3,8.5,2.7,0,7.7
93,2.1,5.6,2.63,2,9,272,8.5,11,0,6.3
97,6.9,3.8,0.12,2,52,178,8.5,0,0,0
553,44,18,6.68,2,12,660,8.5,3.3,0,5.9
97,0.2,1.5,0.8,2,3,212,8.5,11,0,0
57,0.1,0.4,0.18,2,1,116,8.5,3.1,0,9.8
411,17,46,8.57,2,329,1129,8.5,7.1,200,5.7
381,1.4,2,0.8,2,286,110,8.5,2.5,0,65
429,9.5,13,2.28,2,490,241,8.5,14,0,0.5
168,3.7,4.5,8,2,94,76,8.5,0.9,0,0.1
156,1.7,5,17.2,2,207,63,8.5,2.1,0,0.74
130,1.5,2.6,3.16,2,201,117,8.5,1.1,0,0.5
16,0.2,1.2,0.47,2,42,212,8.5,0.9,0,2.63
60,4,3.1,0.08,2,70,234,8.5,0,1,7
407,6.2,4.4,3.81,2,457,51,8.5,2.9,0,55
188,7.2,4.4,24,2,522,91,8.5,2.2,0,0.24
151,2.4,9,37.4,2,438,180,8.5,1,0,1.35
579,50,21,3.71,2,1,733,8.5,13,0,4.4
22,0.3,3.1,0.5,2,5,318,8.5,1,7,2
196,15,14,1.89,2,207,152,8.5,0,88,0.4
76,0.1,1.4,0.72,2,27,230,8.5,2.5,0,5.7
87,0.1,1.9,0.31,2,240,379,8.5,2,0,0.9
45,0.2,0.7,0.2,2,1,200,8.5,0.2,0,8.4
73,1.9,10,0.04,2,34,141,8.5,0,0,3.6
40,0.9,3.2,0.88,2,1,92,8.5,2.6,0,0
1,0,0.2,0.02,2,1,0.2,8.5,0,0,0
486,31,17,7.72,2,16,407,8.5,34,0,0
384,0.9,5.9,19.4,2,571,107,8.5,2.7,286,7.8
1,0,0,0.08,2,1,9,8.5,0,0,0
52,0.2,0.3,0.12,2,1,107,8.5,24,0,10
32,0.3,0.7,0.41,2,1,153,8.5,2,0,4.9
120,1.9,4.4,1.49,2,7,172,8.5,2.8,0,0.9
350,22,4.3,0.75,2,313,362,8.5,3.2,0,2.2
550,50,22,3.4,2,1531,257,8.5,0,0,0
519,34,2.3,1.25,2,6,536,8.5,7.7,0,35
304,0,0.3,0.42,2,4,52,8.5,0.2,0,82
535,30,7.7,2.35,2,79,372,8.5,3.4,0,52
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment