princeml's picture
Update app.py
8facc60
raw
history blame contribute delete
No virus
3.62 kB
import streamlit as st
import pandas as pd
import numpy as np
import joblib
# load the model from disk
filename = 'finalized_model.sav'
loaded_model = joblib.load(filename)
def generate_prediction(input_array):
ans = loaded_model.predict(input_array)
return ans
def main():
# Face Analysis Application #
st.title("Online Food Order Prediction")
activiteis = ["Home", "Prediction","About"]
choice = st.sidebar.selectbox("Select Activity", activiteis)
if choice == "Home":
html_temp_home1 = """<div style="background-color:#6D7B8D;padding:10px">
<h3 style="color:yellow;text-align:center;"> Welcome to world of AI with Prince </h3>
<h4 style="color:white;text-align:center;">
Online Food Order Prediction using Python.</h4>
</div>
</br>"""
st.markdown(html_temp_home1, unsafe_allow_html=True)
st.write("""
Predicting the premium of health insurance
""")
if choice == "Prediction":
val1 = 0
val2 = 0
val3 = 0
val4 = 0
st.header("Predicting the premium of health insurance")
# Define the input fields
age = st.number_input("Age", min_value=0, max_value=120, value=30, step=1)
Bmi = st.number_input("bmi", min_value=0, max_value=1000000, value=50000, step=1000)
children = st.number_input("children", min_value=1, max_value=10, value=4, step=1)
gender = { "Male" :1,"Female" : 0}
Gender_index = st.selectbox("Gender", options=list(gender.keys()))
Gender = gender[Gender_index]
smoke = { "Yes" :1,"No" : 0}
Smoke = st.selectbox("Smoke", options=list(smoke.keys()))
Snoke = smoke[Smoke]
Region = {"northeast" : 1, "northwest": 2,"southeast" : 3, "southwest":4}
Region = st.selectbox("Region", options=list(smoke.keys()))
Region = smoke[Smoke]
if Region == 1:
val1 = 1
if Region == 2:
val2 = 1
if Region == 3:
val3 = 1
if Region == 4:
val4 = 1
# Create a button to trigger the model
if st.button("Predict"):
# TODO: Replace with your model code
prediction = generate_prediction(np.array([[age, Bmi, children, Gender, val1, val2, val3, val4 ]]))
# Show the prediction
st.write("Prediction:", prediction[0])
elif choice == "About":
st.subheader("About this app")
html_temp_about1= """<div style="background-color:#6D7B8D;padding:10px">
<h4 style="color:white;text-align:center;">
Predicting the premium of health insurance .</h4>
</div>
</br>"""
st.markdown(html_temp_about1, unsafe_allow_html=True)
html_temp4 = """
<div style="background-color:#98AFC7;padding:10px">
<h4 style="color:white;text-align:center;">Thanks for Visiting</h4>
</div>
<br></br>
<br></br>"""
st.markdown(html_temp4, unsafe_allow_html=True)
else:
pass
if __name__ == "__main__":
main()
# import streamlit as st