septyoa commited on
Commit
a488f40
·
verified ·
1 Parent(s): 273a9e6

Upload 4 files

Browse files
Files changed (4) hide show
  1. XGBmodel.pkl +3 -0
  2. app.py +40 -0
  3. prediction.py +88 -0
  4. requirements.txt +5 -0
XGBmodel.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5616e5db162a0206f07f7057de10327a04780b3cdaeb548fd003791459853f57
3
+ size 309844
app.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ # Import functions from eda.py and predict.py
4
+ from prediction import make_prediction
5
+
6
+ def main():
7
+ st.sidebar.title("Navigation")
8
+ selection = st.sidebar.radio("Select", ["Home", "EDA", "Prediction"])
9
+
10
+ if selection == "Home":
11
+ st.title("Welcome to our Laptop Price Predictor!")
12
+ st.subheader("",divider = 'gray')
13
+ st.write(
14
+ "This application is build so you don't have to do too much time on researching laptop prices. "
15
+ "Just tell me the specs you want and we'll tell you the price estimation!"
16
+ )
17
+
18
+ st.subheader("Prediction Model")
19
+ st.write(
20
+ "The Prediction section allows you to input your dream laptop specs. "
21
+ "By entering details about the laptop, we will give you a price estimation!"
22
+ )
23
+ st.markdown(
24
+ """
25
+ <style>
26
+ .highlight {
27
+ color: #FF5733;
28
+ font-weight: bold;
29
+ }
30
+ </style>
31
+ """,
32
+ unsafe_allow_html=True
33
+ )
34
+ st.markdown('<p class="highlight">Make informed decisions to enhance your hotel management!</p>', unsafe_allow_html=True)
35
+
36
+ elif selection == "Prediction":
37
+ make_prediction() # Call prediction function
38
+
39
+ if __name__ == "__main__":
40
+ main()
prediction.py ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import pickle # or import pickle if that's what you used to save your model
4
+
5
+ # Load your trained model
6
+ with open('XGBmodel.pkl', 'rb') as file_1:
7
+ XGBmodel = pickle.load(file_1)
8
+
9
+ # Set the title of the app
10
+ def make_prediction():
11
+ st.title('Laptop Price Prediction')
12
+ st.write("MLModel Built by MSABP")
13
+ st.header('',divider='gray')
14
+
15
+ # Create a form for inputting laptop specifications
16
+ with st.form(key='laptop_spec_form'):
17
+ # Input fields
18
+ company = st.text_input("Company")
19
+ product = st.text_input("Product")
20
+ laptop_type = st.selectbox("Type", ["Notebook", "Gaming", "Ultrabook", "2-in-1", "Others"])
21
+ inches = st.number_input("Inches", min_value=0, step=1)
22
+ ram = st.number_input("RAM (GB)", min_value=0, step=2)
23
+ os = st.text_input("Operating System")
24
+ weight = st.number_input("Weight (kg)", min_value=0.0, step=0.1)
25
+ screen = st.selectbox("Screen Resolution", ["Full HD", "4K", "HD", "Others"])
26
+ width = st.number_input("Screen Width (px)", min_value=0, step=120)
27
+ height = st.number_input("Screen Height (px)", min_value=0, step=120)
28
+ touchscreen = st.selectbox("Touchscreen", ["Yes", "No"])
29
+ ips = st.selectbox("IPS Display", ["Yes", "No"])
30
+ retina = st.selectbox("Retina Display", ["Yes", "No"])
31
+ cpu_company = st.text_input("CPU Company")
32
+ cpu_freq = st.number_input("CPU Frequency (GHz)", min_value=0.0, step=0.1)
33
+ cpu_model = st.text_input("CPU Model")
34
+ primary_storage = st.number_input("Primary Storage (GB)", min_value=0, step=64)
35
+ secondary_storage = st.number_input("Secondary Storage (GB)", min_value=0, step=64)
36
+ primary_storage_type = st.selectbox("Primary Storage Type", ["SSD", "HDD", "Others"])
37
+ secondary_storage_type = st.selectbox("Secondary Storage Type", ["No", "SSD", "HDD", "Others"])
38
+ gpu_company = st.text_input("GPU Company")
39
+ gpu_model = st.text_input("GPU Model")
40
+
41
+ # Submit button
42
+ submit_button = st.form_submit_button(label='Submit')
43
+
44
+ if submit_button:
45
+ # Create a dictionary from the input data
46
+ laptop_data = {
47
+ "Company": company,
48
+ "Product": product,
49
+ "Type": laptop_type,
50
+ "Inches": inches,
51
+ "Ram": ram,
52
+ "OS": os,
53
+ "Weight": weight,
54
+ "Screen": screen,
55
+ "Width": width,
56
+ "Height": height,
57
+ "Touchscreen": touchscreen,
58
+ "IPS": ips,
59
+ "Retina": retina,
60
+ "CPU_company": cpu_company,
61
+ "CPU_freq": cpu_freq,
62
+ "CPU_model": cpu_model,
63
+ "PrimaryStorage": primary_storage,
64
+ "SecondaryStorage": secondary_storage,
65
+ "PrimaryStorageType": primary_storage_type,
66
+ "SecondaryStorageType": secondary_storage_type,
67
+ "GPU_company": gpu_company,
68
+ "GPU_model": gpu_model
69
+ }
70
+
71
+ # Convert the input data to a DataFrame for prediction
72
+ input_df = pd.DataFrame([laptop_data])
73
+
74
+ st.subheader('User Input')
75
+ st.write("""This is a view of the data you have entered.
76
+ """)
77
+ st.write(input_df)
78
+
79
+ # Make the prediction
80
+ predicted_price = XGBmodel.predict(input_df)
81
+
82
+ # Display the prediction message
83
+ st.write(f'Based on specs you wanted, the price estimation is: {predicted_price[0]:,.2f}')
84
+
85
+
86
+
87
+ if __name__ == "__main__":
88
+ make_prediction()
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ streamlit==1.32.0
2
+ scikit-learn==1.5.2
3
+ pandas==2.2.3
4
+ seaborn==0.13.2
5
+ matplotlib==3.9.2