Spaces:
Runtime error
Runtime error
File size: 4,846 Bytes
6f177bb |
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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
import streamlit as st
import pandas as pd
import joblib
# import model
with open('SVC_Model.pkl','rb') as file_1:
model = joblib.load(file_1)
st.title("Mobile Price Prediction")
st.subheader("Insert feature to predict")
# user input
battery_power = st.slider(label="Mobile Battery Power", min_value=501, max_value=1998, value=501)
st.write('You Selected : ', battery_power)
blue = st.selectbox(label='Does it have Bluetooth?', options=[0, 1])
st.write('You Selected : ')
if blue == 0:
st.write('No')
else:
st.write('Yes')
clock_speed = st.slider(label='Mobile Clock Speed', min_value=0.5, max_value=3.0, value=0.5)
st.write('You Selected : ', clock_speed)
dual_sim = st.selectbox(label='Does it support Dual Sim?', options=[0, 1])
st.write('You Selected : ')
if dual_sim == 0:
st.write('No')
else:
st.write('Yes')
fc = st.slider(label="Mobile Front Camera Resolution (MP)", min_value=0, max_value=19, value=0)
st.write('You Selected : ', fc)
four_g = st.selectbox(label='Does it support 4G?', options=[0, 1])
st.write('You Selected : ', four_g)
int_memory = st.slider(label="Mobile Internal Memory (GB)", min_value=2, max_value=62, value=2)
st.write('You Selected : ', int_memory)
m_dep = st.slider(label="Mobile Depth (cm)", min_value=0.1, max_value=1.0, value=0.1)
st.write('You Selected : ', m_dep)
mobile_wt = st.slider(label="Mobile Weight (Gram)", min_value=80, max_value=200, value=80)
st.write('You Selected : ', mobile_wt)
n_cores = st.slider(label="Number of Cores", min_value=1, max_value=8, value=1)
st.write('You Selected : ', n_cores)
pc = st.slider(label="Mobile Primary Camera Resolution (MP)", min_value=0, max_value=20, value=0)
st.write('You Selected : ', pc)
px_height = st.slider(label="Pixel Height (px)", min_value=0, max_value=1960, value=0)
st.write('You Selected : ', px_height)
px_width = st.slider(label="Pixel Width (px)", min_value=0, max_value=1998, value=0)
st.write('You Selected : ', px_width)
ram = st.slider(label="Mobile RAM Value (MB)", min_value=256, max_value=3998, value=256)
st.write('You Selected : ', ram)
sc_h = st.slider(label="Screen Height (cm)", min_value=5, max_value=19, value=5)
st.write('You Selected : ', sc_h)
sc_w = st.slider(label="Screen Width (cm)", min_value=0, max_value=18, value=0)
st.write('You Selected : ', sc_w)
talk_time = st.slider(label="Longest time that a single battery charge will last when you are in calls (Hour)", min_value=2, max_value=20, value=2)
st.write('You Selected : ', talk_time)
three_g = st.selectbox(label='Does it support 3G?', options=[0, 1])
st.write('You Selected : ')
if three_g == 0:
st.write('No')
else:
st.write('Yes')
touch_screen = st.selectbox(label='Does it support Touch Screen?', options=[0, 1])
if touch_screen == 0:
st.write('No')
else:
st.write('Yes')
wifi = st.selectbox(label='Does it support Wifi?', options=[0, 1])
if wifi == 0:
st.write('No')
else:
st.write('Yes')
# convert into dataframe
data = pd.DataFrame({'Battery_Power': [battery_power],
'Bluetooth': [blue],
'Clock_Speed': [clock_speed],
'Dual_Sim':[dual_sim],
'Front_Camera': [fc],
'Four_G': [four_g],
'Internal_Memory': [int_memory],
'Mobile_Depth': [m_dep],
'Mobile_Width': [mobile_wt],
'Number_of_Cores':[n_cores],
'Primary_Camera': [pc],
'Pixel_Height': [px_height],
'Pixel_Width': [px_width],
'Bluetooth': [blue],
'RAM': [ram],
'Screen_Height':[sc_h],
'Screen_Width': [sc_w],
'Talk_Time': [talk_time],
'Three_G': [three_g],
'Touch_Screen': [touch_screen],
'Wifi': [wifi]
})
data = data.rename(columns={
'Battery_Power': 'battery_power',
'Bluetooth': 'blue',
'Clock_Speed': 'clock_speed',
'Dual_Sim': 'dual_sim',
'Front_Camera': 'fc',
'Four_G': 'four_g',
'Internal_Memory': 'int_memory',
'Mobile_Depth': 'm_dep',
'Mobile_Width': 'mobile_wt',
'Number_of_Cores': 'n_cores',
'Primary_Camera': 'pc',
'Pixel_Height': 'px_height',
'Pixel_Width': 'px_width',
'RAM': 'ram',
'Screen_Height': 'sc_h',
'Screen_Width': 'sc_w',
'Talk_Time': 'talk_time',
'Three_G': 'three_g',
'Touch_Screen': 'touch_screen',
'Wifi': 'wifi'
})
# interpretation
if st.button('Predict'):
classifications = model.predict(data).tolist()[0]
st.write('Prediction Result : ')
if classifications == 0:
st.subheader('Low Price')
elif classifications == 1:
st.subheader('Medium Price')
elif classifications == 2:
st.subheader('High Price')
else:
st.subheader('Very High Price')
|