Spaces:
Runtime error
Runtime error
import joblib | |
import pandas as pd | |
import streamlit as st | |
model = joblib.load('model.joblib') | |
unique_values = joblib.load('unique_values.joblib') | |
#unique_battery_power = unique_values["battery_power"] | |
unique_blue = unique_values["blue"] | |
#unique_clock_speed = unique_values["clock_speed"] | |
unique_dual_sim = unique_values["dual_sim"] | |
#unique_fc = unique_values["fc"] | |
unique_four_g = unique_values["four_g"] | |
#unique_int_memory = unique_values["int_memory"] | |
#unique_m_dep = unique_values["m_dep"] | |
#unique_mobile_wt = unique_values["mobile_wt"] | |
#unique_n_cores = unique_values["n_cores"] | |
#unique_pc = unique_values["pc"] | |
#unique_px_height = unique_values["px_height"] | |
#unique_px_width = unique_values["px_width"] | |
#unique_px_ram = unique_values["ram"] | |
#unique_px_sc_h = unique_values["sc_h"] | |
#unique_sc_w = unique_values["sc_w"] | |
#unique_talk_time = unique_values["talk_time"] | |
unique_three_g = unique_values["three_g"] | |
unique_touch_screen = unique_values["touch_screen"] | |
unique_wifi = unique_values["wifi"] | |
def main(): | |
st.title("Mobile prices") | |
with st.form("questionaire"): | |
battery_power = st.slider("battery_power",min_value=501,max_value=1998) | |
bluetooth = st.selectbox("bluetooth",options=unique_blue) | |
clock_speed = st.slider("clock_speed",min_value=0,max_value=3) | |
dual_sim = st.selectbox("dual_sim",options=unique_dual_sim) | |
Front_Camera_mega_pixels = st.slider("Front_Camera_mega_pixels",min_value=0,max_value=19) | |
Has_4G = st.selectbox("Has_4G",options=unique_four_g) | |
memory = st.slider("memory",min_value=2,max_value=64) | |
Mobile_Depth = st.slider("Mobile_Depth",min_value=0,max_value=1) | |
Weight = st.slider("Weight",min_value=80,max_value=200) | |
Number_of_cores_of_processor = st.slider("Number_of_cores_of_processor",min_value=1,max_value=8) | |
Primary_Camera_mega_pixels = st.slider("Primary_Camera_mega_pixels",min_value=0,max_value=20) | |
Pixel_Resolution_Height = st.slider("Pixel_Resolution_Height",min_value=0,max_value=1960) | |
Pixel_Resolution_Width = st.slider("Pixel_Resolution_Width",min_value=500,max_value=1998) | |
ram = st.slider("ram",min_value=256,max_value=3998) | |
Screen_Height_of_mobile_in_cm = st.slider("Screen_Height_of_mobile_in_cm",min_value=5,max_value=19) | |
Screen_Width_of_mobile_in_cm = st.slider("Screen_Width_of_mobile_in_cm",min_value=0,max_value=18) | |
longest_time_that_a_single_battery_charge_will_last_when_you_are = st.slider("longest_time_that_a_single_battery_charge_will_last_when_you_are",min_value=2,max_value=20) | |
Has_3G = st.selectbox("Has_3G",options=unique_three_g) | |
Has_touch_screen = st.selectbox("Has_touch_screen",options=unique_touch_screen) | |
Has_wifi = st.selectbox("Has_wifi",options=unique_wifi) | |
# clicked==True only when the button is clicked | |
clicked = st.form_submit_button("Mobile prices") | |
if clicked: | |
result=model.predict(pd.DataFrame({"battery_power": [battery_power], | |
"blue": [bluetooth], | |
"clock_speed": [clock_speed], | |
"dual_sim": [dual_sim], | |
"fc": [Front_Camera_mega_pixels], | |
"four_g": [Has_4G], | |
"int_memory": [memory], | |
"m_dep": [Mobile_Depth], | |
"mobile_wt": [Weight], | |
"n_cores": [ Number_of_cores_of_processor], | |
"pc": [Primary_Camera_mega_pixels], | |
"px_height": [Pixel_Resolution_Height], | |
"px_width": [Pixel_Resolution_Width], | |
"ram": [ram], | |
"sc_h": [Screen_Height_of_mobile_in_cm], | |
"sc_w": [Screen_Width_of_mobile_in_cm], | |
"talk_time": [longest_time_that_a_single_battery_charge_will_last_when_you_are], | |
"three_g": [Has_3G], | |
"touch_screen": [Has_touch_screen], | |
"wifi": [Has_wifi]})) | |
result = if result[0] == 0: | |
result = 'low cost' | |
elif result[0] == 1: | |
result = 'high cost' | |
else: | |
result = 'very high cost' | |
st.success('Your predicted Mobile prices is'+result) | |
if __name__ == "__main__": | |
main() | |
# Show prediction | |
# Run main() | |