Absolute beginner tutorial with computational mixology

Micky C
3 min readFeb 20, 2023

--

Computational mixology is the science of using data and algorithms to create new recipes and combinations of drinks. By analyzing the chemical composition of different ingredients and the preferences of drinkers, computational mixology can produce new and innovative cocktails that are tailored to individual tastes. In this tutorial, we will explore the basics of computational mixology and how it works.

Step 1: Data Collection The first step in computational mixology is to collect data on the chemical composition and sensory qualities of different ingredients. This can be done by analyzing samples of the ingredients in a laboratory or by using databases of existing data. The chemical composition of the ingredients is important because it can affect the way the flavors and textures of the drinks combine.

Step 2: Ingredient Mapping Once the data has been collected, it is important to map the chemical composition of the ingredients into a format that can be easily processed by a computer. This typically involves assigning each ingredient a set of numerical values that represent its chemical composition, such as the percentage of alcohol, sugars, acids, and other flavor compounds.

Step 3: Algorithm Design The next step is to design an algorithm that can use the data to generate new drink recipes. There are several different types of algorithms that can be used for this purpose, including rule-based systems, clustering algorithms, and machine learning models. The goal of the algorithm is to identify combinations of ingredients that are likely to produce interesting and delicious drinks.

Step 4: Recipe Generation Once the algorithm has been designed, it can be used to generate new drink recipes. This typically involves inputting the preferences of the drinker, such as their preferred flavor profiles, and the algorithm will generate a set of recipes that match those preferences. The recipes can be further refined by adjusting the ratios of the ingredients or adding additional ingredients to the mix.

Step 5: Taste Testing Finally, the recipes can be tested by taste testers to determine their sensory qualities and whether they are enjoyable. This feedback can be used to further refine the algorithm and generate new recipes that are even more tailored to individual tastes.

Here’s a sample Python code that implements a basic rule-based system for generating cocktail recipes:

import random
# Define a list of ingredients and their chemical composition
ingredients = {
'gin': {'alcohol': 40, 'juniper': 10, 'coriander': 5, 'citrus': 2},
'vodka': {'alcohol': 40, 'potato': 10, 'wheat': 5, 'citrus': 2},
'rum': {'alcohol': 40, 'molasses': 10, 'caramel': 5, 'vanilla': 2},
'whiskey': {'alcohol': 40, 'barley': 10, 'oak': 5, 'smoke': 2},
'orange juice': {'sugar': 10, 'citrus': 5, 'water': 85},
'tonic water': {'sugar': 10, 'quinine': 5, 'water': 85},
'cola': {'sugar': 10, 'caffeine': 5, 'water': 85},
'grenadine': {'sugar': 40, 'pomegranate': 10, 'water': 50},
'vermouth': {'sugar': 30, 'wine': 50, 'herbs': 20},
'triple sec': {'sugar': 30, 'orange': 50, 'alcohol': 20},
}
# Define a list of rules for combining ingredients
rules = [
{'gin': 30, 'tonic water': 70, 'garnish': 'lime wedge'},
{'vodka': 30, 'orange juice': 70, 'garnish': 'orange slice'},
{'rum': 30, 'cola': 70, 'garnish': 'cherry'},
{'whiskey': 30, 'vermouth': 20, 'triple sec': 10, 'grenadine': 10, 'water': 30, 'garnish': 'lemon twist'},
]
# Define a function for generating a random recipe
def generate_recipe():
recipe = random.choice(rules)
ingredients = []
for name, quantity in recipe.items():
if name != 'garnish':
ingredients.append((name, quantity))
return ingredients, recipe['garnish']
# Test the function by generating and printing a random recipe
ingredients, garnish = generate_recipe()
print('Ingredients:')
for name, quantity in ingredients:
print(f'- {quantity}% {name}')
print(f'Garnish: {garnish}')

This code defines a list of ingredients and their chemical composition, a list of rules for combining ingredients, and a function for generating a random recipe based on those rules. The generate_recipe function randomly selects a rule from the list, extracts the ingredients and quantities from the rule, and returns them as a list of tuples. The garnish for the recipe is also extracted from the rule and returned separately. When the function is called, a random recipe is generated and printed to the console.

Overall, computational mixology is an exciting new field that combines chemistry, data science, and creativity to produce innovative new cocktails and drinks. By using data and algorithms to analyze the chemical composition of ingredients and the preferences of drinkers, computational mixology has the potential to revolutionize the way we think about cocktails and the art of mixology.

--

--