nakere424's picture
Update app.py
08a5e60
import joblib
import pandas as pd
import streamlit as st
model = joblib.load('model.joblib')
bool_list = [True,False]
def main():
st.title("Predict mobile price range")
with st.form("questionaire"):
battery_power = st.slider("Battery Power(mAh)",min_value = 1, max_value = 2000, step=1)
blue = st.selectbox("Have Bluetooth?",options = bool_list)
clock_speed = st.slider("Microprocessor clock speed",min_value = 0.1, max_value = 3.0, step=0.1)
dual_sim = st.selectbox("Have Dualsim?",options = bool_list)
four_g = st.selectbox("Have 4G?",options = bool_list)
m_dep = st.slider("Mobile Depth(cm)",min_value = 0.1, max_value = 1.0, step=0.1)
mobile_wt = st.slider("Mobile Weight(gram)",min_value = 50, max_value = 200, step=1)
n_cores = st.slider("Number of processor core",min_value = 1, max_value = 8, step=1)
px_height = st.slider("Resolution height(pixels)",min_value = 1, max_value = 1960, step=1)
px_width = st.slider("Resolution width(pixels)",min_value = 1, max_value = 2000, step=1)
ram = st.slider("Ram(Megabytes)",min_value = 256, max_value = 4096, step=1)
sc_h = st.slider("Screen height(cm)",min_value = 1, max_value = 20, step=1)
sc_w = st.slider("Screen width(cm)",min_value = 1, max_value = 20, step=1)
touch_screen = st.selectbox("Have touchscreen?",options = bool_list)
wifi = st.selectbox("Have wifi?",options = bool_list)
submitted = st.form_submit_button("Submit")
if submitted:
result=model.predict(pd.DataFrame({"battery_power": [battery_power],
"blue": [blue],
"clock_speed": [clock_speed],
"dual_sim": [dual_sim],
"four_g": [four_g],
"m_dep": [m_dep],
"mobile_wt": [mobile_wt],
"n_cores": [n_cores],
"px_height": [px_height],
"px_width": [px_width],
"ram": [ram],
"sc_h": [sc_h],
"sc_w": [sc_w],
"touch_screen": [touch_screen],
"wifi": [wifi]}))
if result == 0:
result = 'low cost'
elif result == 1:
result = 'medium cost'
elif result == 2:
result = 'high cost'
else:
result = 'very high cost'
st.success("Submitted")
st.text("This mobile phone is "+result)
if __name__ == "__main__":
main()