Built to order

Recipe Recommendation from Available Ingredients using TF-IDF (Food.com Dataset)

This project builds a recipe recommendation system using TF-IDF that ranks Food.com recipes by the ingredients already available at home. The user enters ingredients as chips, the system vectorises each recipe ingredient list, scores cosine similarity, and shows ranked recipes with match percentage, missing ingredients and full cooking steps. Suitable for B.E./B.Tech final-year projects in Computer Science, IT and AI & Machine Learning.

AI & Machine Learning Jupyter notebookHTML · CSS · JavaScriptPython 3 · pandasscikit-learn · TfidfVectorizerCosine similarity rankingFood.com dataset · KaggleSciPy sparse matricesSoftware
Recipe Recommendation from Available Ingredients using TF-IDF (Food.com Dataset) — project thumbnail preview
More project photos (2)

The problem

Most home cooks decide what to cook from whatever is already in the kitchen, yet recipe websites are organised the other way round: pick a dish first, then discover half the ingredients are missing. Searching by a handful of available ingredients is also harder than it looks, because a plain keyword search treats salt, which appears in almost every recipe, as equally important as saffron, which appears in very few. This project builds the search from the pantry outward. Recipes from the Food.com corpus are indexed by their ingredient lists, the pantry is treated as a query, and TF-IDF weighting with cosine similarity ranks recipes so that sharing a rare ingredient counts for more than sharing a universal one. Every result explains itself with a match score, the ingredients already available and the short shopping list that remains.

SYSTEM FLOW

5 components 4 connections

Live flow
Drag to explore
100%
userPantry ingredients

Ingredients the cook already has at home, entered as chips in the demo.

Follow the working sequence

How it works

  1. RAW_recipes.csv from the Food.com release is loaded and cleaned: rows without ingredient lists are dropped, ingredient strings are lower-cased, quantities and preparation words are stripped, and plural forms are normalised to a single token.
  2. A working subset is kept — recipes with complete ingredient lists and a realistic ingredient count — and each surviving recipe is stored as one document made only of its ingredient tokens.
  3. TfidfVectorizer fits the corpus: term frequency is counted inside each recipe and inverse document frequency is computed across all recipes, down-weighting ingredients such as salt and water.
  4. The fitted vectors are stored as a sparse recipe-by-ingredient matrix, so ranking a new pantry does not require refitting the model.
  5. At query time the pantry chips are normalised with the same rules, transformed into the fitted TF-IDF space and compared with every recipe vector using cosine similarity.
  6. Scores are converted to match percentages, recipes are filtered by cooking time, vegetarian flag and the maximum missing-ingredient count, and the survivors are sorted by score.
  7. Each result card shows the have and missing ingredient split, and the detail view renders the full ingredient checklist and cooking steps for the selected Food.com record.

Tech stack:

  • Python 3, pandas (dataset cleaning)
  • scikit-learn TfidfVectorizer, cosine similarity
  • Food.com Recipes and Interactions (Kaggle)
  • Jupyter Notebook (indexing & evaluation)
  • HTML, CSS, JavaScript (web interface)
  • Sparse matrix storage (SciPy)

Dataset & model details

  • Dataset: Food.com Recipes and Interactions, released on Kaggle by shuyangli94 and originally collected from Food.com (Majumder et al., 2019). RAW_recipes.csv holds approximately 231,637 recipes (Approximate, release-dependent) with name, minutes, tags, nutrition, number of steps, steps, description, ingredients and number of ingredients. This implementation indexes a filtered working subset with complete ingredient lists; the exact subset size is recorded in the report for the delivered run.
  • Task: Information-retrieval ranking, not classification. Input = a set of available ingredient names entered by the user. Output = a ranked list of existing recipes with a cosine similarity score, a have/missing ingredient split and the recipe steps. There are no fixed output classes: each recipe is a retrievable document and the ingredient vocabulary forms the feature space.
  • Model: TF-IDF vectorisation (scikit-learn TfidfVectorizer over normalised ingredient tokens) with cosine similarity ranking. No neural network is trained; the fitted IDF weights and the sparse document matrix are the model artefacts.
  • Metrics: Precision@5 and Precision@10, Recall@10, corpus coverage and mean missing ingredients across the top 5, all computed on held-out test pantries in the evaluation notebook. Design target: Precision@5 of 0.70 or above and mean missing ingredients of 1.5 or fewer in the top 5. No performance figure is claimed as measured until the evaluation run is executed for the order.
Parameter Value
Full corpus size Approximately 231,637 recipes in RAW_recipes.csv (Approximate, Kaggle release)
Indexed subset Design target: 20,000–50,000 cleaned recipes with complete ingredient lists
Input 1–15 ingredient names per query (Expected usable range)
Ranking method TF-IDF vectors with cosine similarity (score 0.00–1.00)
Filters Cooking time 15–90 minutes, missing ingredients 0–2, vegetarian toggle
Ranking latency Design target: under 2 seconds per query on a laptop for the indexed subset
Interface Single-page web app, runs in a desktop browser, offline after dataset load
Output per result Match percentage, have/missing split, time in minutes, nutrition calories (Approximate, from dataset field)

Project features

  • [Pantry-first ingredient input] Ingredients are added as removable chips, typed in or tapped from a quick-add list, so the query always shows exactly what the ranking is based on.
  • [TF-IDF recipe index] Every recipe becomes a document of normalised ingredient tokens, vectorised with scikit-learn TfidfVectorizer so rare ingredients carry more weight than near-universal ones.
  • [Cosine similarity ranking] The pantry vector is compared with every recipe vector and results are sorted by cosine score, displayed as a match percentage with the raw score kept visible.
  • [Missing-ingredient shopping list] Each card separates ingredients already in the pantry from those still to buy, and a filter limits results to recipes missing zero, one or two items.
  • [Time and vegetarian filters] A cooking-time slider and a vegetarian toggle narrow the ranked list without re-running the index, mirroring how a cook actually shortlists dishes.
  • [Full recipe detail view] Selecting a result opens the complete ingredient checklist marked against the pantry, the shopping list and the step-by-step method from the dataset record.
  • [Ranking explainer panel] A dedicated view walks through term frequency, inverse document frequency and cosine similarity with the evaluation metrics, so the method can be revised directly from the demo.
  • [Offline evaluation notebook] Held-out test pantries are scored with Precision@K, Recall@K, coverage and mean missing ingredients, with the results table written into the project report.

What is included

  • Complete source code for cleaning, TF-IDF indexing, ranking and the web interface
  • Cleaned Food.com working subset with the preprocessing script that produced it
  • Jupyter notebook covering indexing and the offline evaluation with metrics tables
  • Project report PDF (background, TF-IDF theory, methodology, evaluation, limitations)
  • PPT presentation for final review
  • Viva Q&A preparation document (TF-IDF, IDF weighting, cosine similarity, Precision@K, sparsity)
  • Project abstract PDF

Limitations & prerequisites

  • Recommendations can only come from the indexed Food.com subset; a dish that is not in the corpus can never be suggested, however suitable it would be.
  • Ingredient matching is lexical after normalisation — a synonym or regional name absent from the corpus vocabulary returns no match until a synonym rule is added.
  • Quantities are ignored: the system knows an ingredient is listed, not how much of it the cook actually has at home.
  • Taste, skill level and dietary needs beyond the vegetarian filter are not modelled; the ranking reflects ingredient overlap only.
  • Nutrition values come from the dataset record and are Approximate community-submitted figures, not verified dietary data.
  • Very common pantries (for example salt, onion, oil) produce many similarly scored recipes, so the time and missing-item filters do most of the shortlisting in that case.

Frequently Asked Questions

What is the main technology used in this project?

TF-IDF with cosine similarity, implemented with scikit-learn TfidfVectorizer. Each recipe is one document built from its ingredient list. Rare ingredients receive higher inverse-document-frequency weight, the pantry becomes a query vector in the same space, and recipes are ranked by cosine similarity, then filtered by time and missing-ingredient count before display.

Is this project suitable for a final-year project?

Yes. The work covers dataset cleaning, text normalisation, vectorisation, ranking evaluation with Precision at K and Recall at K, and a working web interface. Those stages map directly onto information retrieval and machine learning syllabus topics, and every design choice, from stop-ingredient handling to the missing-item filter, can be explained and defended during assessment.

Which dataset is used in this project?

The cleaned Food.com Recipes and Interactions release from Kaggle, originally collected from Food.com. This project uses RAW_recipes.csv, which holds recipe names, ingredient lists, preparation steps, tags, cooking time in minutes and a nutrition field. A filtered working subset keeps recipes with complete ingredient lists and realistic ingredient counts for indexing.

Is the recommendation quality guaranteed?

No. No accuracy figure is promised, because recommendation quality depends on the test pantries, the relevance judgements and the filtered subset that is indexed. The report records the Precision at K, Recall at K and mean missing-ingredient count measured in the actual run, and compares them honestly against the design targets stated in the documentation.

Can this project be customized?

Yes, within realistic limits. The ingredient normaliser can be extended with new synonym rules, the time and missing-ingredient filters can be changed in the interface, and the index can be rebuilt on a larger Food.com subset. Adding cuisine filters, nutrition-based re-ranking or a personalised layer from the interactions file is documented as optional extension work.

What are the main limitations of this system?

The ranked list can only suggest recipes that exist in the indexed corpus, and it cannot judge flavour preferences, dietary restrictions beyond the vegetarian filter, or ingredient quantities already in stock. Unusual ingredient names that never appear in Food.com recipes return no match, and very common pantries can produce many similarly scored results needing a tie-break rule.

Components & software requirements
  • Python 3, pandas (dataset cleaning)
  • scikit-learn TfidfVectorizer, cosine similarity
  • Food.com Recipes and Interactions (Kaggle)
  • Jupyter Notebook (indexing & evaluation)
  • HTML, CSS, JavaScript (web interface)
  • Sparse matrix storage (SciPy)

Dataset & model details

  • Dataset: Food.com Recipes and Interactions, released on Kaggle by shuyangli94 and originally collected from Food.com (Majumder et al., 2019). RAW_recipes.csv holds approximately 231,637 recipes (Approximate, release-dependent) with name, minutes, tags, nutrition, number of steps, steps, description, ingredients and number of ingredients. This implementation indexes a filtered working subset with complete ingredient lists; the exact subset size is recorded in the report for the delivered run.
  • Task: Information-retrieval ranking, not classification. Input = a set of available ingredient names entered by the user. Output = a ranked list of existing recipes with a cosine similarity score, a have/missing ingredient split and the recipe steps. There are no fixed output classes: each recipe is a retrievable document and the ingredient vocabulary forms the feature space.
  • Model: TF-IDF vectorisation (scikit-learn TfidfVectorizer over normalised ingredient tokens) with cosine similarity ranking. No neural network is trained; the fitted IDF weights and the sparse document matrix are the model artefacts.
  • Metrics: Precision@5 and Precision@10, Recall@10, corpus coverage and mean missing ingredients across the top 5, all computed on held-out test pantries in the evaluation notebook. Design target: Precision@5 of 0.70 or above and mean missing ingredients of 1.5 or fewer in the top 5. No performance figure is claimed as measured until the evaluation run is executed for the order.
Delivery information

Built-to-order project. Delivery timeline is shared after order confirmation based on current queue.

Support terms

Complete documentation, setup guide, and viva preparation included. Support for setup and explanation provided.

Download free synopsis (PDF)

Enter your name and email — the synopsis PDF downloads immediately. We may send occasional project updates; no spam, unsubscribe anytime.

Get a quotation