Caution to reader: this blog post is 3 months or older. Blog posts older than three months may contain details about the Hack Reactor program that are no longer accurate. Please refer to other pages on our website to confirm current information and email us with questions.
From Amazon to Zappos, recommendation engines have become ubiquitous for a wide range of online businesses. Accurately predicting customer preference based on previous choices mixes technical challenges and judgment calls. A team of students decided to create a beer recommendation app, to help users discover brews in their area well-suited to their tastes.
Beer Me was built by Lauren Pappone, Bo Liu, Mike Lam, Ben Nelson and Iago Prates. They had the challenge of taking hundreds of 1-5 beer ratings, solicited from friends, and creating a program that would find meaningful patterns from these data points. Despite the growing importance of recommendation engines, the available documentation was not helpful.
“There were a lot of resources, but they weren't quite right for what we wanted to do,” says Lam. “The math isn't that hard, but the challenge is how to draw relationships between users.”
Eventually, the team decided on a method in which each users' preferences are summarized as a single data point, with each beer the user has rated representing a unique axis (e.g. a user’s coordinate could be Budweiser: 1, Pabst Blue Ribbon: 3, Anchor Steam: 4). To determine similarity to another user, the app calculates the distance between user’s coordinates, using the beers they have rated in common. This method, called Euclidean Distance, provides reliable comparisons between users, but introduced a different problem:
“One of the drawbacks to using Euclidean Distance as a measure of similarity is that it doesn't account for differences in dimension,” Lam explains. “Here's an example: If I have one beer in common with you, and we rated that beer exactly the same, our similarity index will be the highest it can possibly be (similarity of 1). If another user rated 100 beers in common with me, and we rated all of those beers exactly the same, it wouldn't matter. We'd still have a similarity index of one, and the two of you would both be labeled as having the same relative similarity to me.”
To get around this issue, the team only rated similarity for users who had ranked at least five beers in common. If two users were deemed similar enough (at least 60% similar), they would influence each other’s recommendations.
From there, the group needed to turn those similarity scores into recommendations. Lam explains how they did it in a blog post about how to build a recommendation engine:
“Now that we have our user similarities drawn, in order to generate recommendations for a given user we just have to traverse the graph to find all the users with the highest similarity relationships, find the beers that they like, that our current user hasn't liked yet, and then aggregate the ratings among all of the similar users to provide recommendations to the current user.”
The group also built a function into Beer Me that allows users to name a favorite beer, then have the app recommend similar beers based on objective metrics such as ABV (alcohol by volume) and IBU (international bittering units) as well as common terms like “stout”, “wheat” and “pilsner”. Lam used this feature to identify beers similar to his favorite, Switchback Ale, which is very hard to find outside of Vermont (Beer Me recommended Magic Hat #9 and New Belgium’s Fat Tire).
Want to learn how to build the apps you’d like to see in the world? Apply to Hack Reactor, online or onsite, today!