Skip to content

Commit

Permalink
[Gssoc'23] Added Laptop Price Predictor | Machine Learning Project pr…
Browse files Browse the repository at this point in the history
…anjay-poddar#3136 (pranjay-poddar#3254)

* adding laptop price predictor model

* Update README,md

---------

Co-authored-by: MOHIT GUPTA <[email protected]>
  • Loading branch information
kanishkasah20 and MohitGupta121 authored Jul 9, 2023
1 parent 1eb08d5 commit ee0db53
Show file tree
Hide file tree
Showing 9 changed files with 8,017 additions and 0 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: sh setup.sh && streamlit run app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Laptop-Price-Predictor

This project aims to predict the price of laptops using machine learning techniques, specifically the XGBoost algorithm. The model is trained on a dataset containing various features of laptop, such as the model, ram, sdd, touchscreen, processor, and other relevant factors.

## Dataset

The dataset used for this project consists of a collection of all the laptops, each with associated features and the corresponding price. The dataset is preprocessed to handle missing values, categorical variables, and feature scaling, ensuring the data is suitable for training the XGBoost model.

Dataset link: In the dataset folder(laptop_data.csv)
## XGBoost Algorithm

XGBoost is an optimized gradient boosting algorithm that has gained popularity in machine learning competitions and has become a popular choice for predictive modeling tasks. It is known for its efficiency, accuracy, and flexibility. XGBoost combines multiple weak prediction models (decision trees) to create a strong ensemble model.

## Dependencies

The following dependencies are required to run the project:

-streamlit==1.24.1
-scikit-learn==1.2.1
-xgboost==1.7.6
-pandas==1.5.3
-numpy==1.25.0

To install the required dependencies, you can use the following command:

```shell
pip install xgboost numpy pandas scikit-learn streamlit
```

## Usage
Clone the repository:
```shell
git clone https://github.com/your-username/laptop-price-predictor.git
```
Navigate to the project directory:
```shell
cd laptop-price-predictor
```
Install the dependencies:
```shell
pip install -r requirements.txt
```
Run the Streamlit app:
```shell
streamlit run app.py
```

Open your browser and go to http://localhost:8501/ to access the car price prediction app.

Or you can use the deployed project using the link: https://laptop-price-predictor--eh7dddyzs0h.streamlit.app/

## Disclaimer
The laptop price predictions provided by this project are based on a machine learning model Accuracy of 89.9% and may not always accurately reflect the real market prices. The predictions should be used for reference purposes only, and actual laptop prices can vary due to various factors.
72 changes: 72 additions & 0 deletions Machine Learning Model - Deployment/Laptop-Price-Predictor/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import streamlit as st
import pickle
import sklearn
import pandas as pd
import numpy as np
import XGBRegressor

# import the model
pipe = pickle.load(open('pipe.pkl', 'rb'))
df = pickle.load(open('df.pkl', 'rb'))

st.title("Laptop Predictor")

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

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

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

# weight
weight = st.number_input('Weight of the Laptop')

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

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

# screen size
screen_size = st.number_input('Screen Size')

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

#cpu
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])

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

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

if st.button('Predict Price'):
# query
ppi = None
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 = np.array(query, dtype=object)

query = query.reshape(1,12)
st.title("The predicted price of this configuration is " + str(int(np.exp(pipe.predict(query)[0]))))



Binary file not shown.
Loading

0 comments on commit ee0db53

Please sign in to comment.