Skip to main content
Back

Cookie Science

An exploratory data science and statistical study analyzing 500,000+ Food.com recipes and 1.4M reviews to investigate recipe ratings, data cleaning challenges, and ingredient effects.

Year

2026

Status

Completed Study

Role

Data Science & Statistical Analysis

Project Overview & Research Question

For my first practical data science project, I explored a dataset of Food.com recipes to investigate whether chocolate-containing cookie recipes receive systematically different ratings compared to recipes without chocolate.

The project involved loading CSV files into JupyterLab, inspecting the raw data with Python and pandas, handling missing values and duplicate records, parsing ingredient lists, creating features, conducting exploratory data analysis, and using a statistical hypothesis test to compare average ratings.

More than getting code to execute, the project demonstrated how much reasoning, domain sanity checking, and data auditing are required before a dataset is actually ready for meaningful analysis.

Working with Real-World Data & Cleaning Challenges

Real-world datasets are rarely clean or neatly structured. The recipe dataset contained over 500,000 recipes, while the review dataset contained roughly 1.4 million records. Many recipes lacked matching review records, some ratings were missing, and ingredient formatting was inconsistent.

One major obstacle was that ingredient columns were stored as text formatted like R vectors—for example, c("3/4", "1/2", "1"). A value can visually look like a list without actually being a native Python list.

I wrote a custom parser to convert the text into Python lists. During this process, I discovered that ingredient quantities and ingredient names did not always share identical lengths, meaning elements could not safely be matched by index.

  • Inspected rows, columns, data types, and dimensional integrity across large tables.
  • Separated raw immutable inputs from cleaned analytical datasets instead of mutating in-place.
  • Investigated inconsistencies rather than automatically dropping rows and biasing samples.
  • Built and iteratively validated an ingredient-presence feature to prevent false negatives.

Exploratory Data Analysis & Ceiling Effects

Before jumping into modeling, I produced visual and tabular summaries to understand distributions: histograms of aggregated ratings, ingredient frequency charts, and boxplots comparing chocolate vs. non-chocolate recipes.

The rating histogram revealed a stark ceiling effect: ratings were heavily concentrated near 5.0. When many observations cluster at the upper boundary, variance is compressed, making it harder to detect true quality differentials.

Additionally, while ingredients like flour, eggs, butter, vanilla, and salt were overwhelmingly common, raw frequency does not imply that an ingredient causes higher user ratings.

Statistical Hypothesis Testing

To test the research question ('Are chocolate-containing cookie recipes associated with higher ratings than recipes without chocolate?'), I restricted the analysis to recipes with an aggregated rating and at least five recorded reviews.

This resulted in an analytical sample of 2,136 recipes: 406 classified as chocolate-containing and 1,730 classified as non-chocolate.

A Welch's t-test was conducted to assess whether the small observed rating gap was statistically significant while accounting for unequal variances and sample sizes:

  • Small Difference in Means: The estimated difference was +0.0293 rating points.
  • Confidence Interval Spans Zero: The 95% CI [-0.0136, 0.0723] includes zero, indicating insufficient evidence to reject the null hypothesis at the conventional 5% level.
  • Observational Caveats: This does not prove chocolate has no effect; observational recipe ratings carry subjective noise, omitted variables, and self-selection bias.
  • Measurement Precision: A recipe with five reviews does not have the same precision as one with hundreds of reviews.
{
  "sample_size": {
    "chocolate_recipes": 406,
    "non_chocolate_recipes": 1730,
    "total_recipes": 2136
  },
  "mean_ratings": {
    "chocolate": 4.8091,
    "non_chocolate": 4.7798,
    "difference_in_means": 0.0293
  },
  "welchs_t_test": {
    "95_percent_confidence_interval": [-0.0136, 0.0723],
    "p_value": 0.180,
    "statistically_significant_at_alpha_0_05": false
  }
}

Key Takeaways & Future Work

Connecting foundational spreadsheet intuition (COUNTIF, AVERAGE, STDEV.S, XLOOKUP) with Python and pandas helped clarify what the vector code was doing under the hood.

The biggest takeaway was learning to question results: an error is not always a thrown Python exception. A script can run cleanly to completion while producing misleading outputs if the data transformations or statistical assumptions are flawed.

  • Reconcile recipe-level aggregate ratings with individual user review records.
  • Incorporate review counts into Bayesian shrinkage estimators to account for varying precision.
  • Validate ingredient normalization against edge cases in the raw corpus.
  • Build predictive models with proper train/test splits, cross-validation, and effect sizes.