-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
99 lines (56 loc) · 2.14 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
94
95
96
97
98
99
import streamlit as st
import pandas as pd
import numpy as np
import pickle
file1 = open('pipe.pkl', 'rb')
rf = pickle.load(file1)
file1.close()
# Apple,Ultrabook,8,Mac,1.37,0,1,226.98300468106115,Intel Core i5,0,128,Intel
data = pd.read_csv("traineddata.csv")
data['IPS'].unique()
st.title("Laptop Price Predictor")
company = st.selectbox('Manufacturer:', data['Manufacturer'].unique())
# type of laptop
type = st.selectbox('Type:', data['TypeName'].unique())
# Ram present in laptop
ram = st.selectbox('RAM(in GB):', [2, 4, 6, 8, 12, 16, 24, 32, 64])
# os of laptop
os = st.selectbox('Operating System:', data['OpSys'].unique())
# weight of laptop
weight = st.number_input('Weight of the laptop:')
# touchscreen available in laptop or not
touchscreen = st.selectbox('Touchscreen', ['No', 'Yes'])
# IPS
ips = st.selectbox('IPS( in-plane switching):', ['No', 'Yes'])
# screen size
screen_size = st.number_input('Screen Size in Inches:')
# resolution of laptop
resolution = st.selectbox('Screen Resolution:', [ '1280x800',
'1920x1080', '1366x768', '1600x900', '3840x2160', '3200x1800', '2880x1800', '2560x1600', '2560x1440', '2304x1440'])
# cpu
cpu = st.selectbox('CPU:', data['CPU_name'].unique())
# hdd
hdd = st.selectbox('HDD(in GB):', [0, 128, 256, 512, 1024, 2048])
# ssd
ssd = st.selectbox('SSD(in GB):', [0, 8, 128, 256, 512, 1024])
gpu = st.selectbox('GPU(in GB):', data['GPU brand'].unique())
if st.button('Predict Price'):
ppi = None
if touchscreen == 'Yes':
touchscreen = 1
else:
touchscreen = 0
if ips == 'Yes':
ips = 1
else:
ips = 0
X_resolution = int(resolution.split('x')[0])
Y_resolution = int(resolution.split('x')[1])
if(screen_size<10): screen_size=10
if(weight<1): weight=1
ppi = ((X_resolution**2)+(Y_resolution**2))**0.5/(screen_size)
query = np.array([company, type, ram, os, weight,
touchscreen, ips, ppi, cpu, hdd, ssd, gpu])
query = query.reshape(1, 12)
prediction = int(np.exp(rf.predict(query)[0]))
st.title("Predicted price for this laptop is: " + str(prediction) + " EUR")