MACHINE LEARNING PROJECT:

Abinesh Kannan
4 min readJun 19, 2021

--

Laptop Price Prediction:

In this project, we can predict the price of laptop. We can use laptop specifications as a data to predict laptop prices.

Laptop Price dataset:

In this project, we use laptop pricing dataset. This dataset have 29 rows and 10 columns. Dataset consists of various laptop specifications such as manufacturer, Intelcore(i-), Intelcore Gen, processing speed, ram , HDD, SSD, graphics, ScreenSize, price. Using this dataset we can make our prediction.

Let’s start our project.

Importing libraries:

First, we have to import required libraries. The many library are,

Pandas>>This library is used to import CSV files datasets.

Numpy>> It is used to work with arrays.

Train_Test_Split>> It is used to split the dataset.

from __future__ import print_function

It can be used to use features which will appear in newer versions while having an older release of Python.

np.random.seed(1337)

It will generate the same random number when we run every time.we can use any number in the seed(number).

Importing dataset:

We have to import dataset using pandas. Pandas is used to import CSV file dataset. Import dataset using this line.

Dataset=pd.read_csv(’laptop_pricing.csv’)

Now, we imported the laptop pricing dataset. The shape of dataset is (29,10).

Changing string to numerical values:

In our dataset, we have manufacturer column. This column has laptop company names. This column is in string type. We can’t feed string to machine. So we convert string to numerical values, then we feed easily to machine.

Now all datas are in numerical values, then we go for next process.

Graphical view of dataset:

we have to assign a variable x and y. x contains all columns of dataset except price and y contains a price column in dataset.

Now, we plot a graph of our dataset. It shows the graphical view of our dataset.

Splitting the dataset:

We can split the datas into x_train, y_train, x_test,y_test. These are the training and testing set.

X_train>> it is the training set. It has 21 training set.

Y_train>> it is the labels or target of training set.

X_test>> it is the testing set. Remaining of training set is used as testing set

Y_test>> it is the labels or target of testing set.

We can split this dataset into 75% and 25%.

Training the data:

From SKLEARN import Linear Regression. Linear Regression is a supervised machine learning algorithm where the predicted output is continuous and has a constant slope.

We have to train our data using linear regression model.

Prediction:

Now we have to predict the price using linear regression model. The algorithm is now fully trained. We can predict the price by giving the input as ram , screen size, other specifications. Then the machine will predict the price at high accuracy as possible.

Let’s see the prediction of price. The inputs are: Manufacturer (1),Intelcore(5),IntelcoreGen(9), processing speed (2.40),ram(8),HDD(1000)SSD(0), graphics (4), screen size (15.6). Then the machine predict the output of price as 73773.

Let’s see the accuracy of model is 97%.

--

--

No responses yet