import streamlit as st import pandas as pd #import requests #import json import pickle with open("model.pkl", "rb") as f: model = pickle.load(f) st.write(""" # Mobile Price-Range Prediction\n ## Prices ranges from 0 to 3""") st.sidebar.header("Choose Phone Specs") def input_features(): battery_power = st.sidebar.slider("battery power",500,2000,1000) pix_height = st.sidebar.slider("pix height",0,2000,1000) pix_width = st.sidebar.slider("pix width",0,2000,1000) ram = st.sidebar.slider("ram",400,4000,2000) data = {"battery_power":battery_power, "px_height":pix_height, "px_width":pix_width, "ram":ram} feats = pd.DataFrame(data,index=[0]) return feats, data feats, data = input_features() st.subheader("Phone Specs") st.write(feats) if st.button("Result"): #res = requests.post(url = "http://0.0.0.0:8008/predict", data=json.dumps(data)).text res = model.predict(feats) st.subheader(f"Predicted Price Range: {res[0]}")