Recommendations for recipes displayed in a streamlit application.

Annalie Kruseman b5382b7f04 Convert README.rst to .md 1 month ago
.dvc b5382b7f04 Convert README.rst to .md 1 month ago
figures b5382b7f04 Convert README.rst to .md 1 month ago
recipe_recommendations b5382b7f04 Convert README.rst to .md 1 month ago
tests 51455b5911 Add project. 3 months ago
.DS_Store b5382b7f04 Convert README.rst to .md 1 month ago
.gitignore 5070693b02 Add raw data 2 months ago
.python-version 51455b5911 Add project. 3 months ago b5382b7f04 Convert README.rst to .md 1 month ago
data.dvc 5070693b02 Add raw data 2 months ago
example.png 51455b5911 Add project. 3 months ago
poetry.lock f6e788c6ab Add ipynb checkpoints. 2 months ago
pyproject.toml 538ca883c8 Minor change in README. 2 months ago

Data Pipeline

DVC Managed File
Git Managed File
Stage File
External File

Recipe Recommendations


Often recipe websites contain a filter to look for recipes. Sometimes when you look for a recipe you don’t necessarily know what filter you want to apply exactly. Do you want to filter on recipes with zucchini or carrots? Maybe you don’t mind what kind of vegetable is used when the taste of the dishes are sort of similar. The goal of this recommendation system is to find recipes that are considered similar in taste and composition. And, to challenge your comfortzone with new recipes. In order to do that we use the ingredients of each recipe as the features and calculate how similar to another recipe each recipe is. To build the features we use the bag of words technique. For the similarity metric we use the cosine similarity. The advantage of using a cosine similarity metric is to outweigh the fact that some recipes contain very few ingredients and others contain many. By converting recipes to vectors we only consider the angel between two vectors and not the lenght. Hence, the cosine similarity works well with sparse matrices. The foundation of this recommendation system is a network graph. A network graph will provide a representation of how connected, or similar, recipes are. The resulting network consists only of recipes that exceed the threshold of a similarity score of 0.5. In this example the relations between recipes are explored. However, the concept described here can be applied to many other type of relations between entities or actors.

The result of this recommendation system is presented with the Streamlit application and contains an interactive network made with Plotly and Networkx.

Getting Started


Make sure Streamlit is installed and a python version between 3.6 and 3.8 is running. The python version of this application python 3.8.6. For all prerequisites see the dependencies in the file pyproject.toml.


The data for this application is stored in a personal AWS S3 bucket and retreived with the data version control package DVC. If you would like to replicate this application clone this repository and download the raw dataset, see link at the bottom of this page. .

When downloading the data with DVC it is assumed that the data is stored elsewhere and that DVC is connected. Next, use the following line of code in the same directory in your terminal to fetch the data:

dvc pull

To run the streamlit application and view the recommendation system run:

streamlit run

Alternative to running the streamlit application you may run the raw python code that outputs the recommendation for a particular recipe as an interactive network graph in your browser. Choose a threshold for the similarity metric as the first argument and the recipe as the second argument. To replicate this code run:

python .5 41995


The recommendation system created here is an example of exploring relations between between entities. The data used here consists of text, but the concept can be used for many other applications. Think of a network of people and their behaviors, or a network of connected roads.

The below figure shows an example of the output through the Streamlit application. Recipe Recommendation Network example

Authors and acknowledgment

Annalie Kruseman

Feel free to contact me for any questions on

Dataset downloaded from Kaggles ‘What’s Cooking’