File size: 1,020 Bytes
fb93438
 
c3c364d
 
 
 
 
 
fb93438
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c3c364d
 
fb93438
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
import streamlit as st
import pandas as pd
#import requests
#import json
import pickle

with open(r"C:\Users\lenovo\PycharmProjects\MLOPS\Backend\model.pkl", "rb") as f:
    model = pickle.load(f)

st.write(""" # Mobile Price-Range Prediction""")
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}")