|
import streamlit as st
|
|
import pandas as pd
|
|
import pickle
|
|
|
|
|
|
with open('XGBmodel.pkl', 'rb') as file_1:
|
|
XGBmodel = pickle.load(file_1)
|
|
|
|
|
|
def make_prediction():
|
|
st.title('Laptop Price Prediction')
|
|
st.write("MLModel Built by MSABP")
|
|
st.header('',divider='gray')
|
|
|
|
|
|
with st.form(key='laptop_spec_form'):
|
|
|
|
company = st.text_input("Company")
|
|
product = st.text_input("Product")
|
|
laptop_type = st.selectbox("Type", ["Notebook", "Gaming", "Ultrabook", "2-in-1", "Others"])
|
|
inches = st.number_input("Inches", min_value=0, step=1)
|
|
ram = st.number_input("RAM (GB)", min_value=0, step=2)
|
|
os = st.text_input("Operating System")
|
|
weight = st.number_input("Weight (kg)", min_value=0.0, step=0.1)
|
|
screen = st.selectbox("Screen Resolution", ["Full HD", "4K", "HD", "Others"])
|
|
width = st.number_input("Screen Width (px)", min_value=0, step=120)
|
|
height = st.number_input("Screen Height (px)", min_value=0, step=120)
|
|
touchscreen = st.selectbox("Touchscreen", ["Yes", "No"])
|
|
ips = st.selectbox("IPS Display", ["Yes", "No"])
|
|
retina = st.selectbox("Retina Display", ["Yes", "No"])
|
|
cpu_company = st.text_input("CPU Company")
|
|
cpu_freq = st.number_input("CPU Frequency (GHz)", min_value=0.0, step=0.1)
|
|
cpu_model = st.text_input("CPU Model")
|
|
primary_storage = st.number_input("Primary Storage (GB)", min_value=0, step=64)
|
|
secondary_storage = st.number_input("Secondary Storage (GB)", min_value=0, step=64)
|
|
primary_storage_type = st.selectbox("Primary Storage Type", ["SSD", "HDD", "Others"])
|
|
secondary_storage_type = st.selectbox("Secondary Storage Type", ["No", "SSD", "HDD", "Others"])
|
|
gpu_company = st.text_input("GPU Company")
|
|
gpu_model = st.text_input("GPU Model")
|
|
|
|
|
|
submit_button = st.form_submit_button(label='Submit')
|
|
|
|
if submit_button:
|
|
|
|
laptop_data = {
|
|
"Company": company,
|
|
"Product": product,
|
|
"Type": laptop_type,
|
|
"Inches": inches,
|
|
"Ram": ram,
|
|
"OS": os,
|
|
"Weight": weight,
|
|
"Screen": screen,
|
|
"Width": width,
|
|
"Height": height,
|
|
"Touchscreen": touchscreen,
|
|
"IPS": ips,
|
|
"Retina": retina,
|
|
"CPU_company": cpu_company,
|
|
"CPU_freq": cpu_freq,
|
|
"CPU_model": cpu_model,
|
|
"PrimaryStorage": primary_storage,
|
|
"SecondaryStorage": secondary_storage,
|
|
"PrimaryStorageType": primary_storage_type,
|
|
"SecondaryStorageType": secondary_storage_type,
|
|
"GPU_company": gpu_company,
|
|
"GPU_model": gpu_model
|
|
}
|
|
|
|
|
|
input_df = pd.DataFrame([laptop_data])
|
|
|
|
st.subheader('User Input')
|
|
st.write("""This is a view of the data you have entered.
|
|
""")
|
|
st.write(input_df)
|
|
|
|
|
|
predicted_price = XGBmodel.predict(input_df)
|
|
|
|
|
|
st.write(f'Based on specs you wanted, the price estimation is: {predicted_price[0]:,.2f}')
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
make_prediction() |