Data Analysis Behind Recommendation System: Great Book Reads

Posted on Nov 7, 2021

The skills the author demoed here can be learned through taking Data Science with Machine Learning bootcamp with NYC Data Science Academy.

Github | Linkedin

Data Science Introduction

Recommendation systems have gained huge popularity among eCommerce and online media in the last few years to increase user interaction. Many of our day-to-day choices are driven by personalized recommender systems that are made possible using common data and machine learning algorithms. Some common recommender systems are Netflix suggestions for movies, music on Spotify, Google Ads, and product recommendations on Amazon.

There are two major types of recommendation systems used by most businesses. CONTENT-BASED and COLLABORATIVE. Content-based recommender systems use item features to recommend similar products. For example, if I am a fan of Agatha Christie, the system will recommend me other books from the same author or cozy mysteries from other authors. Collaborative recommender system clusters similar types of users to recommend the item that one user from the cluster has recommended to the other users who did not try the item.

In this article, I have explored the basic concepts behind collaborative recommendation systems using the book feature dataset from Goodreads. As with any other machine learning project, I started with Exploratory Data Analysis and wrapped it up with codes for a basic user-based recommendation system.

Exploratory Data Analysis


The data was collected from UCSD Book Graph. I used the complete book graph from the metadata of books and Book Reviews for this project. A subset of 150k books was used from the book graph dataset containing 27 features including Title, publishers, ratings, image_url, language, etc. The review dataset contained 10k rows of user-id, book id, and user rating which was sorted for books published between 2000-2017 from the book graph dataset. I have used RStudio for this project.


For exploratory data analysis, the following questions were investigated,

  • Number of books published each year
  • How does a number of pages affect popularity?
  • Which books have the maximum versions?
  • What are the most popular languages?
  • How did the popularity of eBooks change in the last decade?
  • Which format is most popular?
  • How are average rating and popularity related?
  • What ratings are more likely?
  • Top 10 publishers and their popularity?

Data on Books Published Each Year

Fig 1 and Fig 2 give the number of publications between 1900-2017 from my dataset. It was seen most books in the dataset were between 2000 and 2017 and rows containing books from these years were filtered out. It was also observed that the number of publications increased after 2007. This is when kindle was launched and ebooks started gaining popularity.


Number of Pages

The number of ratings is considered an estimation of how many people read the book or the popularity. As seen from the scatterplots of the number of pages vs average rating (Fig 4) and the number of pages vs the number of ratings (Fig 5), thick books are less popular but mostly high rated with very few outliers. Most popular books are between 200-400 pages long.

Data on Number of Authors and Different Versions

My dataset has books up to 51 authors. It is seen that books with more than 10 authors are highly rated although the relation is not linear since there were many highly rated single-author books but very few books with more than 10- authors are rated below 3 (Fig 5).

There are few books with many versions including languages, formats, and editions. The most number of versions from my dataset is Stolz und Vorurteil (Fig 6), which is german for Pride and Prejudice. There are 3000 versions of this Jane Austen 1813 novel published in different languages.

Language & format

Analyzing from the bar chart in Fig 8, English is the most popular language followed by Spanish, Arabic, and French. Also, the kindle has a great impact on people's reading behavior. kindle is more popular than all other forms of ebooks.

Data on Average Rating & Popularity

As the number of readers increases, the average rating starts dropping. Reviewing Fig 9, no books with average rating 5 has more than 500 reviews. In the case of books, an average rating of 3.5 or above can be considered safe as long as popularity is concerned. There are critics even for the best works. IT IS DIFFICULT TO KEEP EVERYONE HAPPY!

Fig 9: Average Rating and Popularity


CreateSpace, a self-publishing platform owned by amazon has published the maximum number of books(Fig 10) from the dataset. The books published by CreateSpace are rated high (Fig 11) and are quite popular to acquire the top 10 most number of ratings from my dataset. This is another example of more and more people adapting kindle. Vintage, the New York-based publishing house is the most popular publisher with many highly-rated books.

Fig 12: Top 10 most popular publishers

Popularity of eBooks Data

After Kindle's release in 2007, the popularity of ebooks has grown tremendously. As seen from Fig 13, the number of ebooks sored after 2011. This is when kindle provided its self-publishing platform for freelance and independent writers. In 2011, kindle helped amazon reach $10 Billion in revenue.

Data Analysis Behind Recommendation System: Great Book Reads

Fig 13: Number of ebooks published between 2000 and 2017

Recommendation System

For this project, I have investigated collaborative recommender systems. There are two types of collaborative recommendation systems. Item-Based and User-Based.

Item Based Collaborative Recommender System

The item-based recommender system model was proposed by amazon in 1998. It takes into account the similarity between items and the frequency of users buying the items together. For example, if a user is viewing Agatha Christie's 'the murder of roger Ackroyd, the model will look for users who have already recommended the book before, and then check for books recommended/bought by those users. In the picture (Fig 14), this is done by matching ratings of the books purchased with the current book.

Data Analysis Behind Recommendation System: Great Book Reads

Fig 14: Item-based collaborative Recommender System


User-Based Collaborative Recommender System

In a user-based recommender system, the similarity between users is checked.

As shown in Fig 15, both user1 and user2 are Agatha christie fans and have recommended 3 of her books (who doesn't love her mysteries!!!). Now,user2 recommended Sherlock Holmes, which is a similar genre too. Based on this behavior the model will recommend user1 Sherlock Holmes too. This is a user-based recommender model.


Fig 15: User-based collaborative recommender System

The Basic Maths Behind Gathered Data

To visualize a collaborative recommender system model, we have to first understand the user-item matrix and similarity function. A user-item matrix generated from the book review dataset is shown in Fig 16. Each row represents a user and each column represents a book. The entries are the ratings given by each user to the books they have read. There are a lot of NAs within the matrix since every user hasn't read every book. Due to the ease of computation, a similarity function is introduced.

There are many types of similarity functions, like cosine similarity, Pearson’s correlation coefficient, Euclidean distance, etc. For this project, the cosine similarity function is used (Fig 17). As shown in the matrix (Fig 18), the cosine similarity function can be implemented row-wise (user-based) or column-wise (item-based). The cosine similarity between U1 and U5 is maximum and so the book that U5 has read and U1 has not read will be recommended to U1. For the item-based approach, the cosine similarity between B1 and B5 is maximum, so the user who reads B1 will be recommended B5 if they have not already read B5.

Fig 16: User-Item Matrix



Data Analysis

Top Recommended Books for User 2955

Using the model the following books were recommended to User 2955. The ones with image URLs retrieved the images. Meanwhile, the count column represents the number of similar users and the rating column returned the rating given by those users to the given book.

Top 5 books recommended to user 2955


Future Works

For future work, I am planning to build a hybrid content-based & collaborative recommender system and implement some findings from EDA for filtering (for example, thick books are less popular). A scalable dashboard with the codes at the back end can be generated which could be used by book eCommerce platforms. To test the final model, A/B testing is an essential component as there is no way of telling the effectiveness of a recommendation system model without being implemented for real users.


Mengting Wan, Julian McAuley, "Item Recommendation on Monotonic Behavior Chains", in RecSys'18.

Mengting Wan, Rishabh Misra, Ndapa Nakashole, Julian McAuley, "Fine-Grained Spoiler Detection from Large-Scale Review Corpora", in ACL'19.

About Author


Data Scientist with 5 years experience in Academic Research and supply chain Industry. Expertise in Problem Solving, statistical analysis and machine learning models.
View all posts by SWETA PRABHA >

Related Articles

Leave a Comment

No comments found.

View Posts by Categories

Our Recent Popular Posts

View Posts by Tags

#python #trainwithnycdsa 2019 2020 Revenue 3-points agriculture air quality airbnb airline alcohol Alex Baransky algorithm alumni Alumni Interview Alumni Reviews Alumni Spotlight alumni story Alumnus ames dataset ames housing dataset apartment rent API Application artist aws bank loans 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 boston safety Bundles cake recipe California Cancer Research capstone car price Career Career Day citibike classic cars classpass clustering Coding Course Demo Course Report covid 19 credit credit card crime frequency crops D3.js data data analysis Data Analyst data analytics data for tripadvisor reviews data science Data Science Academy Data Science Bootcamp Data science jobs Data Science Reviews Data Scientist Data Scientist Jobs data visualization database Deep Learning Demo Day Discount disney dplyr drug data e-commerce economy employee employee burnout employer networking environment feature engineering Finance Financial Data Science fitness studio Flask flight delay gbm Get Hired ggplot2 googleVis H20 Hadoop hallmark holiday movie happiness healthcare frauds higgs boson Hiring hiring partner events Hiring Partners hotels housing housing data housing predictions housing price hy-vee Income Industry Experts Injuries Instructor Blog Instructor Interview insurance italki Job Job Placement Jobs Jon Krohn JP Morgan Chase Kaggle Kickstarter las vegas airport lasso regression Lead Data Scienctist Lead Data Scientist leaflet league linear regression Logistic Regression machine learning Maps market matplotlib Medical Research Meet the team meetup methal health miami beach movie music Napoli NBA netflix Networking neural network Neural networks New Courses NHL nlp NYC NYC Data Science nyc data science academy NYC Open Data nyc property NYCDSA NYCDSA Alumni Online Online Bootcamp Online Training Open Data painter pandas Part-time performance phoenix pollutants Portfolio Development precision measurement prediction Prework Programming public safety PwC python Python Data Analysis python machine learning python scrapy python web scraping python webscraping Python Workshop R R Data Analysis 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 seafood type Selenium sentiment analysis sentiment classification Shiny Shiny Dashboard Spark Special Special Summer Sports statistics streaming Student Interview Student Showcase SVM Switchup Tableau teachers team team performance TensorFlow Testimonial tf-idf Top Data Science Bootcamp Top manufacturing companies Transfers tweets twitter videos visualization wallstreet wallstreetbets web scraping Weekend Course What to expect whiskey whiskeyadvocate wildfire word cloud word2vec XGBoost yelp youtube trending ZORI