WOLFRAM

Cheers! A Computational Exploration of Alcoholic Beverages with the Wolfram Language

Cheers! A Computational Exploration of Alcoholic Beverages with the Wolfram Language

For 10 thousand years, humans have been using fermentation to produce beverages for pleasure, rituals and healing. In ancient Greece, honey was fermented to produce mead. Today, popular sources of beverage fermentation are grains, grapes, berries and rice. The science of fermentation—known as zymology (or zymurgy)—is a fascinating blend of chemistry, biology, history and geography. The Wolfram Language now brings a new dimension to the study of alcoholic beverages through an extensive dataset ready to be explored and analyzed.

Alcohol Arithmetic

The Wolfram Language offers more than six thousand functions, including arithmetic functions like Max, Min, Mean and Median. Let’s look at the median alcohol content per serving and default serving size volume for all rums in the alcoholic beverages data:

Engage with the code in this post by downloading the Wolfram Notebook
Median
&#10005


This mimics EntityValue’s default behavior when working with attributed Food entities:

EntityValue
&#10005


You can apply the same calculation to other alcoholic beverages, including "Cognac", "Sake" and "Brandy"—which are all part of the FoodType entity—to see how they compare with "Rum".

Wolfram Language data on the alcohol content of beverages can help when deciding how much to drink. On a night out, approximately how many drafts of beer equate to the usual glass of Chardonnay you have at home? The average glass of wine is about five fluid ounces:

glassOfWine = EntityInstance
&#10005


A serving of draft beer is usually one pint:

draftBeer = EntityInstance
&#10005


So, every pint of beer is equivalent in alcohol content to slightly more than one and a half glasses of wine:

N
&#10005


Knowledge of alcohol content can be useful when designing or choosing cocktails. Once liquors start to mix, it becomes harder to determine the actual alcohol content of the drink. Disclosing this information on menus could help less experienced bar patrons have a better understanding of what’s on offer.

Here’s a function that gets the total alcohol content of a group of alcohols (assuming the density of most alcohols is about one g/mL, the density of water):

totalAlcoholContent
&#10005


Let’s apply this function to a whiskey sour and a gin martini to compare the total alcohol content for these mixed drinks. A whiskey sour is often made with two fl. oz. of whiskey, and a classic gin martini can include two fl. oz. of gin and one fl. oz. of dry vermouth:

whiskeySour = <|  Entity
&#10005


totalAlcoholContent
&#10005


totalAlcoholContent
&#10005


In this example, the martini has a higher total alcohol content than the whiskey sour. But we are leaving the most important question for you to decide—shaken or stirred?

Counting Calories

If you count calories, have you ever wondered whether red wines and white wines differ in calorie content? Do all white wines have similar calories? You can create informative plots that answer questions like these.

First, query the "RelativeTotalCaloriesContent" for both red and white wines using EntityValue:

{redWineCalories, whiteWineCalories} =  DeleteMissing
&#10005


Use ListPlot to visualize the data:

ListPlot
&#10005


ListLinePlot
&#10005


The World of Whiskey

If you enjoy whiskey, geography or travel, GeoBubbleChart can answer the question, “Where in the world are the whiskey producers?” You come away with an informative visualization and an entertaining tongue-twister.

Query the FoodLocation attribute for all whiskeys in the alcoholic beverages data:

whiskeyLocations =  EntityValue
&#10005


Use Interpreter to get the geo positions that correspond to the FoodLocation entities:

geoPositionLookupWhiskey =  AssociationMap
&#10005


Tally the geo positions and then plot them on a GeoBubbleChart to visualize the data:

locationTallyWhiskey = Tally
&#10005


According to the data, the most common locations for whiskey producers are Kentucky, Tennessee, Scotland and Ireland, with less prolific whiskey producers in Canada and Japan. In this way, you could make sure that whiskeys from all around the world are represented in your home collection and explore the flavors produced across different regions.

You can reuse this code to produce another GeoBubbleChart and discover where FoodType values "Rum", "Beer" and "Vodka" are produced globally.

Wine or Beer?

Machine learning and neural networks are prevalent in our everyday lives. You can apply Wolfram Language machine learning to the alcoholic beverages data. Use Classify to train a neural network to distinguish wines from beers based on relative alcohol content:

allWineAlcoholContent =  EntityValue
&#10005


allBeerAlcoholContent =  EntityValue
&#10005


We split the data obtained from EntityValue into a training set (80% of the available data) and a testing set to make sure we can tell how well our ClassifierFunction works on values it hasn’t seen before:

winesDataSplit = With
&#10005


Create the ClassifierFunction:

alcoholClassify = Classify
&#10005


Classify a subset of the testing set data we reserved earlier:

randomBeveragesAlcoholContent = Association
&#10005


alcoholsClassified = alcoholClassify /@ randomBeveragesAlcoholContent;
&#10005


NiceGrid from the Wolfram Function Repository displays a readable grid:

niceGrid = ResourceFunction
&#10005


Flavorful Fruits

The alcoholic beverages available via the Wolfram Language are full of flavors. Several functions give you the ability to explore and visualize the data:

Entity
&#10005


You can continue to explore vodka flavors, like "Mango", "Peach" and "Coconut".

Use Manipulate to investigate other flavored alcoholic beverages:

allAlcoholFlavors =  EntityValue
&#10005


Manipulate
&#10005


Flavors in Focus

The Wolfram Language can visualize data in many different ways. ImageCollage can tell your data story in full color:

vodkaFlavors =  DeleteMissing
&#10005


Find the images corresponding to the vodka FoodFlavor entities:

vodkaFlavorsNames = EntityValue
&#10005


flavorToImageLookup =  AssociationMap
&#10005


Use ImageCollage and Scaled to create a visualization of the most common flavors among vodkas in the Wolfram Language alcoholic beverages data:

imagesWithWeights = Map
&#10005


From this image, we can quickly see that citrus fruits are among the most popular vodka flavors, as well as strawberry, cherry, raspberry, cucumber and coconut. The data reveals some surprising flavors like pumpkin, dragon fruit, espresso and caramel.

WordCloud also provides an interesting weighted visualization of the most common vodka flavors:

WordCloud
&#10005


A Parting Toast

I have enjoyed sharing some of the innovative ways you can analyze and visualize the wide range of alcoholic beverage data now available. I hope you continue to explore Wolfram Language food and beverage data and that you share your exploration with us. (And if you drink, please don’t drive. Arrange a designated driver.) Here’s to our wonderful Wolfram community:

WordTranslation
&#10005


Get full access to the latest Wolfram Language functionality with a Mathematica or Wolfram|One trial.

Comments

Join the discussion

!Please enter your comment (at least 5 characters).

!Please enter your name.

!Please enter a valid email address.

1 comment

  1. We say Kanpai(”乾杯”,”乾盃”) but not Kassai(喝采), as a greeting before drinking :-)

    Reply