Inspiration
Our project was inspired by home office experiences that we probably shared with a lot of people during the current corona pandemic. After a long day at work, immersed in current projects and challenges, you find yourself hungry in front of your fridge in the evening without having planned and shopped for a particular dinner. Since visiting restaurants is no longer an alternative, the challenge is now to cook a delicious meal with the ingredients available. Conventional cookbooks are of little help here, as they suggest special recipes for which we probably lack some crucial ingredients at home. Therefore, our idea is to design an app that suggests such recipes to the user that can be cooked with the ingredients available at home. Over a longer period of use and interaction with the app, it can then also learn the user's personal tastes and suggest adapted recipes in the future.
What it does
In the app, the user specifies the ingredients which are available at home and with which one wants to cook. Based on this input, the user first receives a list of possible dishes as suggestions and can select which of these dishes he or she would like to have displayed as a complete recipe. The user can then rate the suggestion and enable the app to adapt future predictions to his taste.
How we built it
Our app is a web app programmed with Python and Flask. The basis for the recipe predictions is a freely available database with 82k recipes (source: link). In this database, the ingredients of the recipes are already listed as a special column. We have programmed a recommendation engine to find the recipes matching a user input, which calculates a similarity score between all recipes and the ingredient vector defined by the user. For this we use a tf-idf vectorizer and calculate cosine similarities. At the same time, we use various filters on the database to prevent, for example, too many ingredients needed, or to show specifically vegetarian options. In order to personalize the app's suggestions for different users in the future, we used a PostgreSQL database that stores both the users' search queries and their rating of the subsequent suggestions. With enough data, we could use user embeddings for the recommendation engine in the future.
Challenges we ran into
On the content side, we were faced with challenges related to the structural design of cooking recipes and the user behavior we anticipated. Here, a major challenge was the pre-processing of the data in the database, as cooking recipes often contain fancy versions of special ingredients, such as "sesame oil" or "yellow onion". Such recipes can certainly be prepared with a standard oil and an ordinary onion, so you don't want to exclude the recipes even if a user specifies only "oil" and "onion" as ingredients. Thus, in the pre-processing of the data, we had to take care to simplify the ingredients of recipes and exclude unnecessary data from the calculation of the recommendation engine. Another difficulty is that a user will rarely specify the exact ingredients needed for a particular recipe. At the same time, however, it can be assumed that certain basic ingredients such as salt or pepper are present in a typical household. To account for this fact, we have removed some basic ingredients from the ingredient lists and allow our model to suggest recipes that consist of 1.5 times as many ingredients as specified by the user. We also propose a selection of different recipes to the user, so that one has the possibility to click on recipes for which the needed ingredients are at hand. On the technical side, we also had the problem that the data we used was not very well prepared, sometimes containing incomplete recipes or ingredients and incorrect formatting. Also, we were limited in the deployment of our app by the storage capacity of the database, so our predictions are only derived from a total of 7000 recipes, rather than the full 82000. Also, we had to learn about deploying apps first and had some difficulty successfully deploying the local working app to heroku.
Accomplishments that we're proud of
We are proud to have completed the prototype of our app in the given time. We believe that the principle of our app works very well and provides an elegant solution to an actual need. With a better data basis our app should be able to provide significantly improved recipe suggestions. In addition, we have already laid the conceptual foundations for adapting the app to individual users in the future (e.g. by providing them with a user account) and thus making it a real companion in culinary life :-)
What we learned
In this hackathon, we were able to expand our knowledge of deploying Flask applications at Heroku as well as gain experience using SQL Alchemy. We also tried out different models for natural language processing and gained new insights here. Last but not least, after this project we have extended domain knowledge in the area of cooking recipes.
What's next for What-to-cook
As an additional feature of our app we want to give the user the possibility to filter the suggested recipes based on further parameters. For example, you could search for vegetarian recipes or dishes that have less than a certain caloric value per portion. We also want to expand our recommendation engine so that users receive personalized suggestions based on the feedback they have given in previous searches. For this we want to use a deep learning framework instead of the simpler tf-idf vectorizer.
Log in or sign up for Devpost to join the conversation.