File size: 2,746 Bytes
dc9b8f7
 
 
 
 
 
 
 
 
 
 
 
f74fe15
2f90fd2
5e2362a
2f90fd2
 
b5bf44b
b47dab3
 
5e2362a
 
b47dab3
5e2362a
 
2f90fd2
 
64f51b1
 
 
a205572
64f51b1
82f1ffc
64f51b1
 
 
 
 
 
 
 
 
 
 
f88f24c
64f51b1
 
 
 
 
 
 
 
 
fd77829
08a5e60
64f51b1
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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()