-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
93 lines (71 loc) · 2.63 KB
/
app.py
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
#Importing Libraries
import streamlit as st
import pickle
import numpy as np
st.set_page_config(page_title="Laptop Price Predictor", page_icon="💻",
layout="wide")
#import model
st.title("Laptop Price Predictor 💻")
pipe=pickle.load(open("pipe.pkl","rb"))
df=pickle.load(open("df.pkl","rb"))
# making 3 cols left_column, middle_column, right_column
left_column, middle_column, right_column = st.columns(3)
with left_column:
# brand input
company = st.selectbox("Brand", df["Company"].unique())
with middle_column:
# laptop type
type = st.selectbox("Type", df["TypeName"].unique())
with right_column:
# Ram size
ram = st.selectbox("Ram (in GB)", df["Ram"].unique())
# making 3 cols left_column, middle_column, right_column
left_column, middle_column, right_column = st.columns(3)
with left_column:
# Weight input
weight = st.number_input("Weight of laptop in kg")
with middle_column:
# Touchscreen
touchscreen = st.selectbox("Touchscreen", ["No", "Yes"])
with right_column:
# IPS display
ips = st.selectbox("IPS Display", ["No", "Yes"])
# making 3 cols left_column, middle_column, right_column
left_column, middle_column, right_column = st.columns(3)
with left_column:
# screen size
Screen_size = st.number_input("Screen Size (in Inches)")
with middle_column:
# resolution
resolution = st.selectbox('Screen Resolution',['1920x1080', '1366x768', '1600x900', '3840x2160', '3200x1800', '2880x1800', '2560x1600','2560x1440', '2304x1440'])
with right_column:
# cpu input
cpu = st.selectbox("CPU Brand", df["Cpu brand"].unique())
# making 3 cols left_column, middle_column, right_column
left_column, right_column = st.columns(2)
with left_column:
# hdd input
hdd = st.selectbox("HDD(in GB)", [0, 128, 256, 512, 1024, 2048])
with right_column:
# ssd input
ssd = st.selectbox("SSD(in GB)", [0, 8, 128, 256, 512, 1024])
#gpu input
gpu=st.selectbox("GPU Brand",df["Gpu brand"].unique())
#os input
os=st.selectbox("OS Type",df["os"].unique())
if st.button("Pridict Price"):
ppi = None
if touchscreen=="Yes":
touchscreen=1
else:
touchscreen=0
if ips == "Yes":
ips=1
else:
ips=0
X_res=int(resolution.split("x")[0])
Y_res=int(resolution.split('x')[1])
ppi=((X_res ** 2)+(Y_res ** 2))**0.5/Screen_size
query=np.array([company, type, ram, weight, touchscreen, ips, ppi, cpu, hdd, ssd, gpu, os])
query=query.reshape(1, 12)
st.title("The Predicted Price of Laptop = Rs "+str(int(np.exp(pipe.predict(query)[0]))))