This Recommendation Engine Knows Your New Favorite Beer


The craft beer business is booming. With several hundred new breweries opening every year, beer drinkers with discerning palates have more alternatives than ever to the cheap, watery light beers that previously dominated the market.

But craft beer is also a highly regional interest. Lacking the mass production and national distribution of big-name sellers, many craft breweries—especially new shops with limited production and small distribution networks—can only make their beers available to a limited area. Even some of the largest craft brewers only distribute to a portion of the United States, such as Bell’s Brewery from Kalamazoo, Michigan, which is only available in 23 states—most of them on the east coast. This means there’s a ton of great beer that most beer aficionados don’t have access to.

So how, then, does someone in Portland get their hands on some Bell’s Two Hearted Ale? Trade for it, of course!

For as long as there’s been craft beer, so too has there been beer trading. Taking to sites such as Reddit’s r/beertrade subreddit and BeerAdvocate’s trading forum, thirsty hopheads spout acronyms such as ISO (in search of) and FT (for trade), offering up their local bottle shop’s prized stock in exchange for a rare brew from across the country.

Luke Armistead built the recommendation engine soon to be implemented with The Beer Exchange.

Galvanize Data Science graduate Luke Armistead built the recommendation engine soon to be implemented with The Beer Exchange.

But now there’s an easier option. The Beer Exchange is a beer trading company that helps would-be beer traders get their hands on otherwise inaccessible craft offerings. Created by North Carolina-based entrepreneur and self-described craft beer fanatic Mark Iafrate, the website pairs together users who have a coincidence of beers they’re looking for and beers they have access to, streamlining the tiresome process of finding a suitable trade partner.

“The Beer Exchange can get you the beer you want,” said Luke Armistead, a graduate of Galvanize Data Science and longtime friend of Iafrate. “The problem is: it can’t tell you the beers you might want, which is the logical next step of the business.”

How Can You Trade For What You’ve Never Heard Of?

As with most community-based services, The Beer Exchange works best with a critical mass of users and, in this particular case, thickly populated wish lists—each user’s list of “in search of” beers they’re interested in trading for. The more beers users put on their wish lists, the more potential trade partners The Beer Exchange can recommend. But with so many new breweries popping up across the country every year, there’s a great deal of beer out there that many would-be traders have never even heard of.

To that end, Armistead developed a recommendation engine that suggests new beers to users based upon the other beers they’ve added to their wish list. Built in Python and using a variety of packages, such as Pandas, NumPy, and GraphLab Create, Armistead’s recommender uses collaborative filtering to determine which other beers a user might also like, due to similarity not in style or flavor, but rather latent features determined by other users who also like those beers.

In building the recommender, Armistead first had to determine a way to measure interest in a particular beer. For users on The Beer Exchange, there are three primary actions that indicate interest. The first is adding a beer to your wish list—indicating some baseline level of interest. The second is proposing a trade for a beer—a greater interest level than simply adding it to your wish list. The third and highest level of interest is actually completing a trade for a beer.

“Completing a trade involves all the pain in the ass of negotiating a trade and evaluating the trustworthiness of your counterpart,” Armistead said, “as well as actually getting your hands on the beer you’ve offered up for trade, packaging it very carefully, setting up shipping—there’s a lot of roadblocks there. To me, that represents the strongest signal.”


After trying out a variety of combinations of the various interest indicators, Armistead ended up focusing solely on completed trades. The effort required to complete a trade represents an extremely strong signal in determining interest, and thus provides the most relevant information for training his recommendation engine model.

The trick to Armistead’s recommender, and collaborative filtering in general, is in examining the users that express interest in a particular beer—not the actual traits (hoppiness, bitterness, maltiness, etc.) of the beer itself. The technical term is called Jaccard similarity, which is defined as the size between the intersection divided by the size of the union of two sets. In our case, this means the similarity between two beers is determined by the users that they have in common divided by the total list of users that like either one.

A simple version would look like this: when a user adds a beer to his or her wish list, Armistead’s recommender looks for all of the users who have traded for that beer. It then looks at all the other beers those users have traded for, finds the commonality, and recommends them back to the original user. Of course, in practice this is done on a much larger scale, looking at thousands of trades across a multitude of users, resulting in what is referred to as clustering.

circular_graph 2

“The fun part of clustering this way is that you pick up on patterns that aren’t delimited by the type of a beer,” Armistead said. “For example, folks that like IPAs tend to also like porters, even though those are very different types of beer in terms of taste and how they’re made.”

While collaborative filtering based upon completed trades has thus far proven to be the most successful, Armistead’s engine tests a number of other machine learning models (such as non-negative matrix factorization or item-similarity) to continually ensure the best results are being found. If a user adds a recommended beer to their wish list, it’s considered a successful recommendation. Through A/B testing, the engine then iteratively learns which model is performing the best, based upon which produces the most successful recommendations.

In addition to integration with The Beer Exchange in the next two months, Armistead has made a standalone version of his beer recommender called Savvy Suds available online. The online version takes in up to three beer choices, then recommends five beers as per the engine’s clusters. While it doesn’t perform quite as well as the full Beer Exchange integration (three beers is a much more limited snapshot of information to work with than a fully formed wish list), Savvy Suds offers an easy way to quickly discover some new beers.

As for The Beer Exchange itself, Armistead says Iafrate is in the process of applying to several top incubators. The service currently boasts close to 20,000 beer aficionados and is growing rapidly by word of mouth. The company has also begun partnering with bottle shops across the country and recently launched a sort of beer marketplace—letting users buy directly from far away stores rather than jumping through all of the hoops of trading in the first place. Even so, its role in facilitating trades of Pliny the Elder cannot be understated.

“If nothing else, it’s given me a justification for all the craft beer that I drink,” Armistead said.

Want more data science tutorials and content? Subscribe to our data science newsletter.

[[formassembly formid=432325]]