Laptop Recommendation Machine Learning System

Posted on Sep 24, 2019

Have you wonders what makes a laptop expensive? Which specs have the most significant impact on the price? I will be answering these questions through machine learning.


Laptop has become one of the most essential and used items in our daily life. However, I am sure that you have struggled to choose the personal laptop that fits your needs? With the overwhelming amount of specifications and brand names on the market, it becomes difficult for laptop makers to sell their products and for customers to pick their laptop.

Why should we care about this problem? In 2019, estimable of 166 million units of laptops were sold and shipped in 2019 (International Data Corporation). The average selling price for a laptop sits at around 629 U.S. Dollars. The global laptop market size is calculated to be around 100 billion dollars and with an anticipated market size of 108.9 billion by 2025, according to a study by Grand View Research. Laptops will continue to rise in demand as growing spending capacities of consumers and upsurge in demand for technologically advanced products. As laptops are selling across the world, people and manufacturers alike will have to be knowledgeable and competitive.

Project Motivation:

  1. Quantify what quantity quality of a laptop contributes the most across the 3 categories of laptop.
  2. Discover laptop trends across different brands, types, and performances.
  3. Predict laptop prices base on quantity quality such as ram space, storage amount and type, CPU and GPU relative performance, brand, type, and screen size.
  4. KNN Recommendation System - laptop recommendation based on specifications.

Data Acquisition: Web Scraping

The amount of scraping needed to scrape the target market are insurmountable. To simplify the analysis and data collections, I decided to focus mainly on three categories of laptop data to gather: Personal, Business, and Gaming. For the machining learning perspective, I scrape my training datasets from Newegg and BestBuy, and my test datasets from B&H Photovideo.

From these three websites, I scrape the specifications and price of three categories of laptop. Specifications from the lap ranges from their screen size to their refresh rate to their CPU. Fig 1 shows the field of data I scrape from Newegg, Bestbuy, and B&H Video. In total, there were around 10 datasets from the three websites, and each of the datasets was around 1000-4000 rows and 40 columns. With a total of around 20000 rows and 40 columns.

Data Cleaning:

As expected, datasets from different website has different formatting and columns name for the data. For example, in the Newegg datasets (Fig.2), there are a total of 38 columns and 6000 rows. To simplify the cleaning process, I combine the personal, business, and gaming laptop datasets from the same website into one data frame.


First, I take a look at the total number of missing values and fill some missing values based on logical principles. For instance, I replace all missing SSD and HDD with zero, because some computers do not have an SSD or HDD. Besides, the majority of personal computers does not contain a dedicated graphics card; therefore, I replace those with 0 and compare them in a different category. After filling in as many missing values as I can, I remove all columns with more than 10% missing values, shown in Fig.3.

Then, I remove all row with null CPU, RAM, and 0 total storage capacity, because no computer can run with a CPU, storage, and RAM. These randomly missing data are due to new products where specs are not available or/and employees did not post the specs according to the posting guidelines.

Next, I check the type of variable in each column, and almost all columns are string objects. Thus, the cleaning process begins, I converted every column that has a number, such as the weight, storage, dimension, screen size, etc. into quantitative variables.

The computer algorithm has a hard time understanding words such as intel 9720X and Nvidia GTX1080. What is next is convert CPU and GPU string into a quantitative figure. To convert GPU and CPU into standard benchmark data, I scrape and to get all of the respective benchmark numbers. (Shown in Fig.4)

Fig.4 A sample of the CPU benchmark score

I use the Knuth-Morris-Pratt string search algorithm to maximum efficiency of the search algorithm and manage to convert around 99% of the CPU and GPU column into actual benchmarks. With this step completed, some visualizations are created using python's Seaborn package.

Data Visualization and Trend Discussion

Brand Price Trend

The brand trend for the three different types of laptops: business, personal, and gaming.

For Business laptopsApple and Lenovo have the highest mean and median price. It is not surprising since Lenovo owns Thinkpads and apple have their 13.3 and 15 inches MacBook Pro line. Dell, HP, and Acer, these three brands have a much lower average laptop price. It makes sense since these three companies are known for cheaper and has a much more traditional laptop feel and design.

For Gaming laptops, it is no surprise, in the year 2019, Razer, Gigabyte and Alienware have the highest mean and median price in the gaming category. Razer blade laptop and Alienware have dominated the high-end gaming laptop market for years. There are, however, many outliers in this category of laptop. For example, MSI, ASUS, Razer, and Gigabyte all have that one series of super-high-end laptops that gear toward these customers.

For Personal laptops, again, expensive brand laptops such as Razer, Gigabyte, Alienware, Apple, and MSI are amount the top 5 of the highest mean and median price laptops. While austere style personal laptops are majority controlled by brands such as HP, Huawei, Lenovo, Dell, Asus, and Acer.

Screen Size Frequency

In 2019, the preferred screen size is 15.6 inches for all three types of laptop. It is not a surprise to see no gaming laptop below 15.6 inches since gaming below the 15.6 inches ruining the gaming experiences. Also, there are very few business laptops that around 15.6 inches, because portability is a high valued specification in the work environment. Finally, for the laptop listed in 2019, there are very few that are below the screen size of 13.3 inches.

CPU and GPU regression graph vs. Weight

The weight and performance of a laptop are one of the most crucial specification customer looks for. As one can expect, the heavier the laptop, the performance of CPU and GPU also increases. More space and weight means faster and better hardware. However, in 2019, the high-end laptop is no longer as constricted as before; there are many high-speed CPU available for between the 2 to 4 lbs. (SUPER LIGHT).

On the other hand, if one is looking at the GPU, there is still a limitation on 2019's technology. If you are looking for a high-gear GPU, the lowest weight is around 4 lbs. As expected, the laptop's graphics card takes precious space and other additional hardware, such as fans, to properly function. Thus, the weight limitation for high-end GPU laptop in 2019 is around 4 lbs.

CPU and GPU regression graph vs. Price Trend

CPU and GPU benchmarks are directly proportional to the price of the laptop. However, it is possible in 2019 to purchase highly CPU and GPU focus laptop for around the 1000 dollar range. This is a prime example of Moore's Exponential Growth Law. Around 8 years ago, a 3000 dollars laptop would only get a CPU and GPU of benchmark around 2500 and 2000In 2019, one can expect a CPU and GPU benchmark around 21000 and 19000, respectively. Around a 10X increase in just 8 years.

Use Machine Learning to predict price and build a recommendation

Price Prediction and Model Accuracy

I want to see if a laptop from Newegg and Bestbuy can accurately predict the price of the laptop from B&H VideoPhoto. Before fitting a linear model, I first dummify some of the variables and created custom featuring engineering to reduce the complexity of the model. Then, I normalize all variables with a skewness higher than 0.15. Then I split the data into training and test set, using Newegg and Bestbuy laptop as the training set, and using B&H VideoPhoto as another. I want to see if the model can predict laptop prices across the websites.

Ridge Linear Regression

XBGboosting Regression

The first image was the residual plot from using Ridge Linear Regression after parameter tuning using grid search cross-validation; it receives an r^2 of 0.69.

The second image was the residual plot from XBGboosting Regression. After parameter tuning using a 5-fold cv grid search, it receives a model score of 0.79 on the testing data.

From these two residual plots of these two models, one can see that there are a couple of outliers that completely throw both models entirely off. However, overall, both models perform fairly decent and further suggest that all three website has very similar prices laptop.

K-Nearest Neighbor Recommender

With the linear model, we were able to predict the price of the computer-based on its spec. The next thing that interests me was to build a recommendation system based using a K-Nearest K Nearest Neighbors model. K-nearest neighbors which rely on euclidean distance requires data to be scale.

I use Min Max Scalers to scale my dataset before putting it in the KNN model.

Critical points on Min-Max Scalers:

  • We subtract the min from all values and marking a scale from Min to Max.
  • Divide it by the difference between Min and Max
  • Result is that our values will go from zero to 1
  • Downside is that we will have lower standard deviations and it suppresses the effect of outliers

From the picture below, I was able to create a recommendation based on the user input. In this case, I was looking for a 15.6inch MSI gaming lapto

I check the recommendations and well, it works! It recommended my current laptop that I research for a few weeks to get. To my surprise, despite such a simple approach, the recommender does pick up the difference between different laptop specs.

Future Work

In the interest of further analyzing other factors that increase/decrease laptop price and understand review affect on laptop price, it would be of interest to:

  1. Scrape the average rating and review a summary of each laptop and use sentimental analysis to rank each of the laptops.
  2. Create more feature engineering relating different specifications, such as whether the laptop contains a USB-C port or what version of Bluetooth support.
  3. Use and test different types of scalers on the data-set and understand its effect on the model prediction.

Jayce is currently working on these new data science projects. If you are a huge basketball fan or just a data nerd, check out his basketball player cluster analysis and NBA player comparison tool.

About Author


Jayce Jiang

Jayce Jiang is previously an NYC Data Science Fellow and Data Engineer with a Dual Bachelors Degree in Aerospace and Mechanical Engineering from the University of Florida. He currently a founder of Strictly By The Numbers,, and...
View all posts by Jayce Jiang >

Leave a Comment

No comments found.

View Posts by Categories

Our Recent Popular Posts

View Posts by Tags

#python #trainwithnycdsa 2019 airbnb Alex Baransky alumni Alumni Interview Alumni Reviews Alumni Spotlight alumni story Alumnus API Application artist aws beautiful soup Best Bootcamp Best Data Science 2019 Best Data Science Bootcamp Best Data Science Bootcamp 2020 Best Ranked Big Data Book Launch Book-Signing bootcamp Bootcamp Alumni Bootcamp Prep Bundles California Cancer Research capstone Career Career Day citibike clustering Coding Course Demo Course Report D3.js data Data Analyst data science Data Science Academy Data Science Bootcamp Data science jobs Data Science Reviews Data Scientist Data Scientist Jobs data visualization Deep Learning Demo Day Discount dplyr employer networking feature engineering Finance Financial Data Science Flask gbm Get Hired ggplot2 googleVis Hadoop higgs boson Hiring hiring partner events Hiring Partners Industry Experts Instructor Blog Instructor Interview Job Job Placement Jobs Jon Krohn JP Morgan Chase Kaggle Kickstarter lasso regression Lead Data Scienctist Lead Data Scientist leaflet linear regression Logistic Regression machine learning Maps matplotlib Medical Research Meet the team meetup Networking neural network Neural networks New Courses nlp NYC NYC Data Science nyc data science academy NYC Open Data NYCDSA NYCDSA Alumni Online Online Bootcamp Online Training Open Data painter pandas Part-time Portfolio Development prediction Prework Programming PwC python python machine learning python scrapy python web scraping python webscraping Python Workshop R R language R Programming R Shiny r studio R Visualization R Workshop R-bloggers random forest Ranking recommendation recommendation system regression Remote remote data science bootcamp Scrapy scrapy visualization seaborn Selenium sentiment analysis Shiny Shiny Dashboard Spark Special Special Summer Sports statistics streaming Student Interview Student Showcase SVM Switchup Tableau team TensorFlow Testimonial tf-idf Top Data Science Bootcamp twitter visualization web scraping Weekend Course What to expect word cloud word2vec XGBoost yelp