Neighbors Know Best: (Re) Classifying an Underappreciated Beer
A look at beer features to determine whether a specific brew might be better served (pun intended) by being classified under a different style. kNN analysis supported with in-post plots and linked iPython notebook.
By Reginal Eps, EndlessPint.
Not One Thing
Beer is delicious but it is not one thing. If you disagree with the former part of the previous sentence please keep the latter in mind. Think of sports, for instance. Many would agree with the blanket statement "sports are fun" but depending on what you have in mind two people can easily have opposite reactions to being presented the opportunity to play ping-pong. Sports are not one thing, music is not one thing, and neither is beer.
Presented with a finely crafted brew in a style of your preference it is difficult to have a more pleasurable gastronomical experience. Throw off one of those two criteria, craftsmanship or style preference, and you're likely to have a decent experience at best or an off-putting one at worst.
I was recently dismayed to find that a beer I had been enjoying, Naughty Boy , a purported stout made in collaboration by two Dutch breweries, LOC and de 3 Horne, was not particularly well received. Upon reading the online reviews I was convinced that the reviews were unwarranted. Something was missing and whether from my perspective or others was what I went about investigating.
Difference of Expectation, Difference of Opinion
Of the fourteen top reviewers that rated this on RateBeer (Accessed: 24 July 2016) eleven mentioned “bitter” , and some more than once. Consumers naturally have predefined ideas about what they are getting into. I believe the misplaced expectations of what a stout should taste like left reviewers surprised, and clearly not always in a pleasant way.
Is Naughty Boy a stout or is it a black India Pale Ale (BIPA)? The color and roast undertones say “stout”. The nose and forward flavor say “hops”. Expectations help determine experience and I believe the brewer is shortchanging themselves and their customers by possibly mis-categorizing this beer.
Data Collection & Analysis
In an effort to bear this out I collected data for 108 Dutch beers, 36 apiece for the styles stout, India Pale Ale (IPA), and BIPA. This was a simple two dimensional feature set consisting of alcohol by volume (ABV) and international bitter and units (IBU), which determine, you guessed it, the level of bitterness found in a beer. Though ABV numbers were available for all beers I was not as fortunate when it came to the IBU numbers. Upon removing NaN’s from the collection I was left with a total of 71 beers: 28 IPA, 27 BIPA, and 16 stouts.
Working with two primary features made it simple to visualize the data via a scatter plot, with ABV on the x-axis and IBU on the y-axis. I included a third feature in the plot by differentiating the dots by beer style using different colors and shapes for quick identification. Implementing a simple one nearest neighbor (1-nn) function I color-coded the entire background region by the color of the nearest beer and superimposed the beers on top of this new background. The final step prior to running any analysis was standardizing the features due to the difference in scale (ABV: 2–14, IBU: 0–120) and re-creating the plot.
With the above data and visualization preparation in hand I went about training a k-nearest neighbor (kNN) model using scikit-learn. By running a 10-fold cross validation on a range of k (from 1 to 31) I determined that for this limited data set (and yes, we should use more data) k==2 would be the likeliest candidate for generalizing on unseen data.
The next steps from here should have been clear and straightforward: standardize the features of LOC's Naughty Boy and submit it to the model for classification. As luck would have it, we found ourselves with a similar limitation a second time, LOC does not provide the IBU for Naughty Boy. Apparently this is a little shtick of theirs that extends to other beer collaborations. We had come too far to turn back now, besides the fun had just started and it now became clear that the visualization would prove to be more than simply ornamental.
Improvisation & Conclusion
We took the one beer feature that was available, ABV, and standardized it; next we plotted all candidates for the entire IBU range of this ABV; lastly, each of the candidate points above were then categorized by their two closest beer style neighbors and colored in based on scores. Naughty Boy occasionally receives a vote for “stout”, but never without a matching IPA or BIPA vote. In fact, the IPA and BIPA votes occur most often and are the two styles that represent unanimous categorizations. Above a certain IBU, fifty-five, there are no votes for stout as a style.
If Naughty Boy has an IBU of 55 or greater I argue its creators should reconsider its style and thereby, hopefully, re-calibrate expectations, improve experiences, and raise the estimation of a possibly unfairly maligned beer.
"First off we have to say that you are absolutely right and we actually regretted not dry hopping Naughty Boy and set the style to session BIPA. But then when brewing a collab you can't precisely do as you want all the time." - Daniel, LOC Brewery
 It depends on your perspective but one of the other pleasures of good/craft beer is coming across all types of ridiculous names.
 The bitterness I experienced in drinking this beer was hop-based.
Original. Reposted with permission.
- Barley, Hops, and Bayes: Predicting The World Beer Cup
- Bayesian Machine Learning, Explained
- When Good Advice Goes Bad
Top Stories Past 30 Days