The Guardian Food Recipes — Topic Modeling
By: Aude Vuilli
Tags: Food, Topic Modeling, Towards Data Science, NLP, Data Journalism

The Guardian Food Recipes by recipes from The Guardian

Introduction

The food section of The Guardian invites amateur chefs to explore the boundless culinary world, to engage with new ingredients and flavours, to learn cooking techniques or to get ideas for celebratory feasts.

In the first blogpost of this series, I told you about my passion for food and my curiosity about data science. I presented you with some exploratory data analysis of the last 10 years of recipes published daily by The Guardian.

The aim of this article is to engage with topic modelling. This method is useful to discover the abstract “topics” occurring in a collection of documents. It allows to rapidly understand the meaning of a long text, extracting its keywords and categorizing its content.

Do you love pie and tarts, do you fancy salads or cakes, do you prefer fish or meat? By the end of the article, you will know which Guardian chef columnists to call to cook your next dinner party!

If you are too hungry to wait for the end, you may already want to look at the recipes here.

The Guardian Food Recipes — Yotam Ottolenghi’s chilled cucumber and yoghurt soup (photo by Louise Hagger), Claire Thomson’s spiced filo pumpkin pie (photo by Jean Cazals), Meera Sodha’s mee goreng (photo by Louise Hagger), José Pizarro’s clams ‘a la plancha’ (photo by Martin Poole), Henry Harris’ roast partridge and spiced blackberries (Ola O Smit), Nigel Slater’s figs with pistachio biscuits (photo by Romas Foord)

Data and Methods

After collecting 7,361 recipe articles from The Guardian, with the oldest one dating back to the 3rd of January 2009 and the most recent being from the 16th of June 2019, I first cleaned the textual data in a Python notebook.

Some preliminary steps are necessary to perform Topic Modelling. These steps involve the formatting of the textual data: tokenization, stopwords removal as well as lemmatization. For more details about each of these steps, have a look at the article from Susan Li.

Diverse techniques can be employed to do topic modelling. In this post, I chose to use Latent Dirichlet Allocation (LDA). To get a stronger taste of how LDA works, you can read the original research paper from David M. Blei and al. or a more digestible article from Félix Revert. Greg Rafferty blog post series on Harry Potter is also a great resource.

Fiona Beckett’s Wine Selection for Seafood (photo by The Picture Pantry), Yotam Ottolenghi’s tomato with lime and cardamom yoghurt (photo by Louise Hagger), Vicky Bennison’s cappellacci with pumpkin, Jeremy Lee’s bloody mary (photo by Martin Poole), and Anna Jones’ roast peaches with vanilla and thyme.

Recipes Topic Modeling

The following table and graphs show the outcomes of the Gensim LDA models. The pre-processing steps made were to:

Choose the LDA models. Here I used Gensim (Variational Bayes Sampling) and Mallet (Gibbs Sampling).

Determine the number of topics. After visualizing the model coherence score against the number of topics, I decided to train the model with 24 different topics. The best coherence score with Gensim being 0.48.

Assign a Topic Name to each of the 24 latent topics according to the top 10 keywords of the model outputs.

Compute the dominant topics for some of the most contributing chefs to the recipes of The Guardian.

It is worth to take the following insights with a little grain of salt! Gensim’s and Mallet’s LDA models bore most of the time ripe fruits, but also some sour one. Thus, I chose to select only recipe articles that were matched to soft and juicy fruits and disregard the other one. This means, that from my total recipes harvest, around 20% of them were left aside (attribute to the topic as “other” in the table below).

Topic Modeling, Topics Name

The outcomes of the Mallet model can be compared to recipes’ ingredients. Whereas the ingredients are the keywords and the dishes are the documents.

Some topics or if you prefer dishes are easy to identify. For example, the keywords “drink, wine, cocktail, glass, …” can quickly be associated with recipes link to drinks and cocktails, similarly “fish, mussel, salmon, fillet, …” are without doubt referencing to recipes containing fish. For others, it requires a little more interpretation! What do you think of the following pairing? Does it suit your taste, or would you recommend something else?

The table gives an overview of LDA Mallet Topic Modeling results. The Topic Weight shows the probability of a document having a particular topic, the Topic Name shows the name assigned to the Mallet topic keywords.

Main Topics of recipes’ chefs

In part I, I look at the chefs having contributed the most to The Guardian recipes over the years. While each chef likes everything from soup to nuts, they usually stand out according to their type of cuisine. Could this be noticed by looking at all their recipes? Well, by assigning each of the recipes to their dominant topic, this may give us a nice piece of cake!

Tiko Tuskadze’s apple, fennel and beetroot borscht (photo by Jonathan West), Thomasina Miers’ prawn bun cha (photo by Louise Hagger), Ken Yamada’s wild mushroom ramen (photo by Louise Hagger), Chad Parkhill’s negroni, and Mary Berry’s milk chocolate cake (photo by Ola O Smit)

Among the most contributing authors to The Guardian recipes, Nigel Slater, Thomasina Miers, Yotam Ottolenghi or Anna Jones can be mentioned. What distinguishes them from one another? Who recipes should you have a look at, if you fancy fish or meat for dinner, or if you prefer a bowl of soup with a piece of tart?

At first glance, the results seem to be a little bit tasteless! A majority of the chefs’ recipes are about vegetables, sides or soups. But takes another bite, and some spices will become noticeable.

Lover of the sea or pastures, you may be captured by the meat and fish dishes by Nigel Slater, Angela Hartnett or Hugh Fearnley-Whittingstall. Lover of the world, you will preferably travel will Yotam Ottolenghi, Thomasina Miers or Anna Jones with their curry and Asiatic dishes.

To whet your appetite, Nigel’s autumn menu is a suite of comfortable dishes with pumpkin, beetroot, spinach pastry, beef rib boulangere and raspberry mille-feuille. Anna Jones, however, proposed some winter salads or mouthwatering welsh cakes.

The doughnuts charts show the three most famous men and the three most famous women chefs contributing to The Guardian. The doughnuts illustrate the percentage of their recipes belonging to each of the different categories.

A diner is never completed without having a little dessert! Dan Lepard, Felicity Cloake and Ruby Tandoh are probably the sweetest chefs of the Guardian. The classification of their recipes shows clearly that they are master of pastries, cakes and biscuits! So, if you fancy being part of the next Great British Bake Off, you should enjoy reading these authors!

The doughnut charts show the three most famous chefs writing recipes for baking. The doughnuts illustrate the percentage of their recipes belonging to each of the different categories.

Holiday dishes, exotic meals, or festive drinks are equally important that other meals! Rachel Roddy, Meera Sodha and Henry Dimbleby know it well! If you always wanted to visit Italy and taste the traditional pasta dishes, Rachel Roddy will learn you all about it. If you prefer travelling further East, into a colourful and spicy world, then Meera Sodha will guide you through the world of curry, dal, mee goreng and bahn mi. And if you need something to get a little bit cheerful, then Henry Dimbleby may have a recipe for it!

The doughnut charts show the classification of Rachel Roddy, Meera Sodha and Henry Dimbleby’s recipes. The doughnuts illustrate the percentage of their recipes belonging to each of the different categories.

Conclusion

This article has explored LDA Topic Modelling on 7,361 food recipes published in The Guardian from January 2013 to June 2019. It has shown that LDA Topic Modelling is a helpful tool to get insights into famous British chefs recipes. However, it has also shown some limitations: some recipes could not be classified with LDA.

This is partly because of some of the recipe articles present an entire menu, sides, mains, and desserts altogether. But it also due to the fact that cooking can be thought of as a “topic”: Chopping, slicing, cutting, peeling, heating are all techniques that are used to create mouthwatering dishes. Without knowing if they apply to an apple, a tomato or some potatoes, it remains difficult to know if you will end up with a dessert or a salad!

If you are interested in seeing my preprocessing steps, how I picked, washed, chopped, seasoned and finally arranged the numerous data, you can have a look at my GitHub repository over here! For Interactive Visualization over here!

Thanks for reading! Aude

Before cleaning the dishes!

I hope you enjoyed the post and if you’d like to leave any comments, suggestions or thoughts, I would really appreciate it! So please, feel free to reach out!

In the next blog post, I aim to engage with word clouds and visualize the top ingredients used over the years, the seasons and by each of the chefs.

I am a Data and Plant Scientist at Vertical Future, previously at WBCSD. MSc. in Urban Analytics and Smart Cities from UCL The Bartlett CASA in London and BSc. in Food Science from ETH Zurich. Passionate about cities, food, and health get in touch via Twitter or LinkedIn.