Laptop Recommendation Machine Learning System
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.
- Quantify what quantity quality of a laptop contributes the most across the 3 categories of laptop.
- Discover laptop trends across different brands, types, and performances.
- 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.
- 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.
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 cpubenchmark.net/ and videocardbenchmark.net/ 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 laptops, Apple 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 2000. In 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
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.
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:
- Scrape the average rating and review a summary of each laptop and use sentimental analysis to rank each of the laptops.
- Create more feature engineering relating different specifications, such as whether the laptop contains a USB-C port or what version of Bluetooth support.
- Use and test different types of scalers on the data-set and understand its effect on the model prediction.