File size: 1,483 Bytes
0cb5a8a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import numpy as np
import pickle

pipe = pickle.load(open('pipe.pkl','rb'))
df = pickle.load(open('df.pkl','rb'))

st.title("Laptop Price Predictor")

company = st.selectbox('Brand',df['Company'].unique())


type = st.selectbox('Type',df['TypeName'].unique())


ram = st.selectbox('RAM(in GB)',[2,4,8,12,16,24,32,64])


weight = st.number_input('Weight of laptop')


touchscreen = st.selectbox('Touchscreen',['No','Yes'])


ips = st.selectbox('IPS',['No','Yes'])


screen_size = st.number_input('Screen Size')


resolution = st.selectbox('Screen Resolution',['1920x1080','1600x900','3840x2160','3200x1800','2560x1600','2560x1440','2304x1440','1366x768','2880x1800'])


cpu = st.selectbox('CPU',df['Cpu brand'].unique())


hdd = st.selectbox('HDD(in GB)',[0,128,256,512,1024,2048])


ssd = st.selectbox('SSD(in GB)',[0,8,128,256,512,1024,2048])


gpu = st.selectbox('GPU',df['Gpu Brand'].unique())


os = st.selectbox('Os',df['os'].unique())


if st.button('Predict Price'):
    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: "+str(int(np.exp(pipe.predict(query)[0]))))