Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import joblib
|
3 |
+
import numpy as np
|
4 |
+
|
5 |
+
|
6 |
+
# load the model from disk
|
7 |
+
loaded_model = pickle.load(open(filename, 'rb'))
|
8 |
+
result = loaded_model.score(X_test, Y_test)
|
9 |
+
print(result)
|
10 |
+
|
11 |
+
|
12 |
+
def generate_prediction(input_array):
|
13 |
+
ans = loaded_model.predict(input_array)
|
14 |
+
|
15 |
+
return ans
|
16 |
+
|
17 |
+
|
18 |
+
def main():
|
19 |
+
# Face Analysis Application #
|
20 |
+
st.title("Online Food Order Prediction")
|
21 |
+
activiteis = ["Home", "Prediction","About"]
|
22 |
+
choice = st.sidebar.selectbox("Select Activity", activiteis)
|
23 |
+
|
24 |
+
if choice == "Home":
|
25 |
+
html_temp_home1 = """<div style="background-color:#6D7B8D;padding:10px">
|
26 |
+
<h3 style="color:yellow;text-align:center;"> Welcome to world of AI with Prince </h3>
|
27 |
+
<h4 style="color:white;text-align:center;">
|
28 |
+
Online Food Order Prediction using Python.</h4>
|
29 |
+
</div>
|
30 |
+
</br>"""
|
31 |
+
st.markdown(html_temp_home1, unsafe_allow_html=True)
|
32 |
+
st.write("""
|
33 |
+
Online Food Order Prediction
|
34 |
+
""")
|
35 |
+
if choice == "Prediction":
|
36 |
+
val1 = 0
|
37 |
+
val2 = 0
|
38 |
+
val3 = 0
|
39 |
+
val4 = 0
|
40 |
+
|
41 |
+
st.header("Online Food Order Prediction")
|
42 |
+
# Define the input fields
|
43 |
+
age = st.number_input("Age", min_value=0, max_value=120, value=30, step=1)
|
44 |
+
|
45 |
+
Bmi = st.number_input("bmi", min_value=0, max_value=1000000, value=50000, step=1000)
|
46 |
+
|
47 |
+
children = st.number_input("children", min_value=1, max_value=10, value=4, step=1)
|
48 |
+
|
49 |
+
gender = { "Male" :1,"Female" : 0}
|
50 |
+
Gender_index = st.selectbox("Gender", options=list(gender.keys()))
|
51 |
+
Gender = gender[Gender_index]
|
52 |
+
|
53 |
+
|
54 |
+
smoke = { "Yes" :1,"No" : 0}
|
55 |
+
Smoke = st.selectbox("Smoke", options=list(smoke.keys()))
|
56 |
+
Snoke = smoke[Smoke]
|
57 |
+
|
58 |
+
|
59 |
+
|
60 |
+
Region = {"northeast" : 1, "northwest": 2,"southeast" : 3, "southwest":4}
|
61 |
+
Region = st.selectbox("Region", options=list(smoke.keys()))
|
62 |
+
Region = smoke[Smoke]
|
63 |
+
if Region == 1:
|
64 |
+
val1 = 1
|
65 |
+
if Region == 2:
|
66 |
+
val2 = 1
|
67 |
+
if Region == 3:
|
68 |
+
val3 = 1
|
69 |
+
if Region == 4:
|
70 |
+
val4 = 1
|
71 |
+
|
72 |
+
|
73 |
+
# Create a button to trigger the model
|
74 |
+
if st.button("Predict"):
|
75 |
+
# TODO: Replace with your model code
|
76 |
+
prediction = generate_prediction(np.array([[age, Bmi, children, Gender, val1, val2, val3, val4 ]]))
|
77 |
+
|
78 |
+
# Show the prediction
|
79 |
+
st.write("Prediction:", prediction[0])
|
80 |
+
|
81 |
+
elif choice == "About":
|
82 |
+
st.subheader("About this app")
|
83 |
+
html_temp_about1= """<div style="background-color:#6D7B8D;padding:10px">
|
84 |
+
<h4 style="color:white;text-align:center;">
|
85 |
+
Online Food Order Prediction with Machine Learning .</h4>
|
86 |
+
</div>
|
87 |
+
</br>"""
|
88 |
+
st.markdown(html_temp_about1, unsafe_allow_html=True)
|
89 |
+
|
90 |
+
html_temp4 = """
|
91 |
+
<div style="background-color:#98AFC7;padding:10px">
|
92 |
+
<h4 style="color:white;text-align:center;">Thanks for Visiting</h4>
|
93 |
+
</div>
|
94 |
+
<br></br>
|
95 |
+
<br></br>"""
|
96 |
+
|
97 |
+
st.markdown(html_temp4, unsafe_allow_html=True)
|
98 |
+
|
99 |
+
else:
|
100 |
+
pass
|
101 |
+
|
102 |
+
if __name__ == "__main__":
|
103 |
+
main()
|
104 |
+
|
105 |
+
|
106 |
+
|
107 |
+
# import streamlit as st
|
108 |
+
|
109 |
+
|
110 |
+
|