AI Engineering Blog | Read the AI Articles | Monolith

pancAIke day and machine learning | Monolith AI

Written by Admin | Feb 10, 2021 12:00:00 AM

Why would you want to use machine learning for baking?

 

Maybe you're wondering, "Couldn't you just read a recipe book or one of the 63,400,000+ recipes discoverable via google?".

Sure, we could do that. But with lockdown #42 walloping us, no intention to go beyond the first page of Google results and boredom hitting an all-time high, it made sense to mix work with culinary pleasure. 

What if I wanted to make pancakes for ten people, sure, I'm social distancing, but when this lockdown ends, I'll have friends over if I have any left. What if, I had a lot of flour but didn't know how much baking powder to add? The whole point is to experiment with different ratios of ingredients and be confident the outcome will be the desired type of pancake - fluffy and not rubbery. 

 

Enter Machine Learning

 

This is an excellent fit for Machine Learning because we can gather recipe data and train a model to identify its patterns. Also, because we have Monolith AI, it's meant for engineers to create better products; from engines like a CFM56-5B for an Airbus A320 to conducting transient state testing on prototype cars. But manufacturing isn't that difficult from cooking, and we already covered this when we tried to bake the best cookies using Machine Learning

 

Creating the dataset

 

Luckily, there is no scarcity of recipes on the internet, or on Kaggle. We found over 800 recipes for American style fluffy pancakes. However, we needed recipes with enough positive and negative reviews to train the model to predict what amount of ingredients would give us the fluffiest pancakes. 

After elimination, we ended up with a dataset of 31 recipes with enough reviews to train a model to predict the right output.

To keep the problem relatively simple, we only looked into the following ingredients:

  • Flour 
  • Baking soda or baking powder
  • Milk
  • Eggs
  • Butter
  • Salt
  • Sugar

We noticed that some recipes recommended a rest time for the batter. So, we added that into our dataset too. 

 

Processing the data

 

When it comes to utilising Machine Learning data, a lot of time is spent on cleaning data sets or creating a dataset free of errors. Even though Data Cleaning is rarely mentioned, it is critical for any Machine Learning application's success. Turn your data waffle into a data pancake and let the maple syrup flow! Too much? Ok, I'll tone it down. 

 

 

Training the model

 

We decided to conduct a train-test split procedure to estimate the performance of Machine Learning model; it's when the model is used to make predictions on data that are not used to train the model. Since we have a small dataset, we used k-fold cross validation and hyperparameter optimisation to get better results. 

 

 

Model prediction looks good, with an average error of 25%, this will be even less once we add a larger dataset. Now we can setup scalar prediction and create a dashboard where we can vary ingredients and see what the likely outcome is. This will allow us to change the amount of single or multiple ingredients and gauge how good the pancakes would be. 

 

Insights

 

We learned that three ingredients affect the quality of our pancakes above others:

  • Baking powder
  • Sugar
  • Milk
  • Butter

We presume the perfection of a pancake is less sensitive to alterations in these other ingredients. All these ingredients work together to create fluffy pancakes. The baking powder causes the formation of CO2. This gas, in turn, creates bubbles in the batter.

The gluten molecules in flour are elastic, and the fat (milk and butter) and sugar positively affect the development of gluten. When these molecules combine, they create a tight network of proteins that trap the bubbles. This allows the pancakes to stay fluffy and in shape even after cooking.

The sugar also helps with the Maillard reaction (this is what causes the 'browning' of pancakes)

We asked our platform to give us three recipes that would give us fluffy pancakes and here's one of them:

  • Flour - 210 g
  • Sugar - 48 g
  • Baking powder - 14 g
  • salt - 6 g
  • Eggs - 2
  • Milk - 256 g
  • Butter - 25g

Although we didn't train a model for the cooking directions but following general practice:

  • Mix the dry ingredients (flour, sugar, baking powder and salt)
  • Whisk the eggs and add the milk and melted butter
  • Combine the dry and wet ingredients, don't overmix, lumps are a good thing
  • On a medium heat pan, pour enough batter to achieve the size you want
  • cook on one side until bubbles form and the edges of the pancake start to solidify
  • flip once and only once

Always make the first pancake as your test cake or "chef's snack," to make sure that you have the heat just right.