tushargandhi77 commited on
Commit
e4c747a
1 Parent(s): 966710f

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +68 -0
app.py ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import numpy as np
3
+ import pickle
4
+
5
+ pipe = pickle.load(open('pipe.pkl','rb'))
6
+ df = pickle.load(open('df.pkl','rb'))
7
+
8
+ st.title("Laptop Price Predictor")
9
+
10
+ company = st.selectbox('Brand',df['Company'].unique())
11
+
12
+
13
+ type = st.selectbox('Type',df['TypeName'].unique())
14
+
15
+
16
+ ram = st.selectbox('RAM(in GB)',[2,4,8,12,16,24,32,64])
17
+
18
+
19
+ weight = st.number_input('Weight of laptop')
20
+
21
+
22
+ touchscreen = st.selectbox('Touchscreen',['No','Yes'])
23
+
24
+
25
+ ips = st.selectbox('IPS',['No','Yes'])
26
+
27
+
28
+ screen_size = st.number_input('Screen Size')
29
+
30
+
31
+ resolution = st.selectbox('Screen Resolution',['1920x1080','1600x900','3840x2160','3200x1800','2560x1600','2560x1440','2304x1440','1366x768','2880x1800'])
32
+
33
+
34
+ cpu = st.selectbox('CPU',df['Cpu brand'].unique())
35
+
36
+
37
+ hdd = st.selectbox('HDD(in GB)',[0,128,256,512,1024,2048])
38
+
39
+
40
+ ssd = st.selectbox('SSD(in GB)',[0,8,128,256,512,1024,2048])
41
+
42
+
43
+ gpu = st.selectbox('GPU',df['Gpu Brand'].unique())
44
+
45
+
46
+ os = st.selectbox('Os',df['os'].unique())
47
+
48
+
49
+ if st.button('Predict Price'):
50
+ if touchscreen=='Yes':
51
+ touchscreen = 1
52
+ else:
53
+ touchscreen = 0
54
+
55
+ if ips =='Yes':
56
+ ips = 1
57
+ else:
58
+ ips = 0
59
+
60
+ X_res = int(resolution.split('x')[0])
61
+ Y_res = int(resolution.split('x')[1])
62
+
63
+ ppi = ((X_res**2) + (Y_res**2))**0.5/screen_size
64
+
65
+ query = np.array([company,type,ram,weight,touchscreen,ips,ppi,cpu,hdd,ssd,gpu,os])
66
+
67
+ query = query.reshape(1,12)
68
+ st.title("The Predicted Price: "+str(int(np.exp(pipe.predict(query)[0]))))