← Back to the case study

Code: What makes drinkware buyers unhappy, and can an AI sort the reviews?

Every number on the case study page comes from these files. View any file in the browser, download one, or get them all as a zip.

FileWhat it doesOpen
analysis.pyThe data checks, the two AI checks (stars, calibration), the routing rule and the brand comparison. Writes results.json.View · Download (13.0 KB)
run_model.pyAsks the decision model (Laya) the typed questions for every review and saves its probabilities.View · Download (2.9 KB)
llm_code.pyThe codebook prompt Claude used to name the main complaint of each one- and two-star review, and a re-run.View · Download (2.9 KB)
fetch_data.pyStreams the public Amazon Reviews 2023 files and draws the 2,000-review sample.View · Download (5.4 KB)
build_page.pyBuilds the case study page from results.json.View · Download (21.1 KB)
results.jsonEvery number on the page.View · Download (3.7 KB)
ai_answers.csvThe decision model's answers for every review (goes in data/).View · Download (49.8 KB)
llm_complaints.csvClaude's main complaint for each of the 300 one- and two-star reviews (goes in data/).View · Download (4.7 KB)

Download all (drinkware-reviews.zip)

Run it yourself

  1. python3 fetch_data.py (streams 41 GB of public files; writes data/reviews.csv)
  2. Put ai_answers.csv and llm_complaints.csv in data/ (the AI answers used on the page). To make new ones instead: pip install laya, then python3 run_model.py (about 40 minutes on a laptop processor) and python3 llm_code.py.
  3. pip install pandas numpy
  4. python3 analysis.py
  5. python3 build_page.py

Data: Amazon Reviews 2023 (McAuley Lab, UC San Diego) · model Laya (Apache 2.0) · Claude (Anthropic). The data files are not re-hosted here; the links go to the original source.