How New York Tweets About Food, Part 2

In part 1 of this series, we discovered a few things: the number of tweets about pizza dwarfs most other foods, burgers are a more popular lunchtime tweet than other foods, and that I completely ignored breakfast. In part 2, we’ll not only see when New Yorkers tweet about food, but also how they feel about their food.

Background #1: Sentiment Analysis
Over the past three weeks, a server somewhere in the world has been quietly pulling down New Yorkers’ tweets related to eleven different foods: pizza, bacon, cereal, tacos, burgers, bagels, spinach, kale, tofu, scrambled eggs, and quinoa. The sentiment of each tweet was analyzed using a naive Bayesian classifier, the same technique used in early spam filters. This method categorizes single words as positive (“awesome”, “delicious”), neutral, or negative (“terrible”, “crappy”), then examines each word in a tweet to determine whether there are a critical mass of positive or negative words. As you might guess, the method is far from perfect. A tweet such as “the worst thing about this pizza is that I can’t eat it every day”, for example, would be tagged as negative. With a sufficient volume of data — nearly 500,000 tweets for this analysis — this becomes less of an issue. 

Background #2: Net Promoter Score
If you haven’t fallen asleep yet, I suggest getting a pillow now. We have one more thing to cover before getting to the good stuff. A Net Promoter Score, or NPS, is a metric used to measure customer satisfaction. If you’ve ever been asked “How likely are you to recommend this service to a friend or colleague?”, you have been part of an NPS score. Respondents answer this question on a scale of 1 to 10. The NPS score is calculated as the number of 9’s and 10’s (promoters) less the number answering 6 or less (detractors) divided by the total number of respondents. I applied this same concept to the food analysis: the NPS values calculated below equal the number of positive tweets less the number of negative tweets divided by the total tweets.

Total Number of Tweets by Food
Now on to the graphs. First, let’s revisit a few things now that we have nearly 500,000 tweets collected over a three-weeks period. In terms of raw count, pizza reigns supreme (see what I did there?), while the new kid on the block, cereal, makes a surprising appearance in the top 3:

Weekend Foods vs. Weekday Foods
Which foods are more popular on weekends? According to Twitter, at least, tofu, bagels, and pizza are the most weekend-ish foods, while scrambled eggs are most popular on weekdays.

Food Tweets by Time of Day
The first time around, the only common breakfast food analyzed was bacon, leading me to add “cereal”, “scrambled eggs”, and “bagel”. As it turns out — and contrary to a frequent Twitter complaint — tweeting about breakfast just isn’t that popular.

Also surprising: the profile of weekend (Saturday, Sunday) food-related tweets isn’t so different from weekday food tweets. The biggest delta is between 6:30 and 8:30 AM — outside of that, tweets are sent with generally similar frequencies.

Tweets by Day of Week
Affirming a finding from my earlier post, Saturday is the least popular day to tweet about food (we have better things to do!… or maybe eat different foods?) while Thursday is the most popular.

Sentiment and NPS by Food
The following chart shows the percentage of total tweets, by food, that were categorized as positive or negative. Cereal had the highest percentage of negative tweets, while bacon (!) was second. Scrambled eggs and quinoa had the highest proportion of positive tweets. The most controversial foods (i.e., those with the fewest neutral tweets) were quinoa, cereal, and scrambled eggs. The most “meh” foods were tofu, tacos, and kale.

When looking at an NPS-style score for each food, scrambled eggs and quinoa come out on top, while tacos and cereal are the cellar-dwellers.

Food Sentiment on Weekends vs. Weekdays
Across all foods studied, there is no discernible difference in weekday versus weekend sentiment. When looking at individual foods, however, there are some big jumps in sentiment. Quinoa and tacos are discussed more favorably on weekdays, while cereal has almost twice the NPS on weekends as it does on weekdays.

Sentiment Throughout the Day
One other fun way to slice our data is to look at sentiment at different times of the day. As a general rule, food-related tweets are most positive early in the day. But the most amazing feature of this chart is the “valley of regret” between 2:15 and 3:15 PM.

And that’s all she wrote! I don’t know about you, but I’m stuffed.



How New York Tweets About Food, Part 1

I’ve been meaning to play around with the Twitter API for quite some time now. After warming up by analyzing the relationship between followers, people followed, tweets, and account longevity, I set out to study how New York Tweets about food. So, one week ago, I set up a script that hit Twitter’s search API every minute and pulled down tweets about a variety of foods.

For no particular reason, I chose to study bacon, burgers, kale, pizza, quinoa, spinach, tacos, and tofu. Here’s how often New Yorkers tweeted about these foods across the week:


A number of interesting trends stand out. It’s important to keep in mind, though, that we’re only working with one week’s worth of data. And it was a strange week weather-wise, including several 100-ish degree days and a freak Wednesday afternoon hailstorm.

Caveats aside, Monday was the least popular day of the week to tweet about food; it saw about 6% fewer tweets about food than average. Wednesday was the most popular day, with 11% more tweets than average. Saturday and (strangely) Thursday are the only days with more lunch tweets than dinner tweets. On that note, here’s what an average day looks like:

Here we see in more detail that — for the foods selected, at least — breakfast is the least popular meal to tweet about. But the foods selected impact these results significantly. Even though I pulled down data for eight different foods, pizza accounted for a whopping 50% of the total food-related tweets. Bacon came in second at 10%. Quinoa and tofu, unsurprisingly, represented a paltry 2% of the total tweets collected. 

With the exception of bleary-eyed college students, most of us don’t make a breakfast out of pizza, which means that the chart above is skewed toward lunchtime, dinner, and late night dining. The data prove this; of the foods studied, pizza saw the lowest number of tweets during breakfast. The following chart shows the share of tweets about a given food that occurred during each hour of the day: 

Interestingly, burger tweets spike around lunchtime, yet don’t last as long into the night as pizza does. Tacos see relatively more late-night tweets than any other food, and are the least popular breakfast food. In general, it’s clear that I’ve chosen a sample of foods that are tilted toward lunch and dinner. For the curious, here are the patterns for each of the healthier foods. All show a similar, dinner-centric pattern:

With a handful of insights in hand, I’m going to tweak the script over the next week. I’m also going to blend in some sentiment analysis, which means we’ll know how people feel about their food in addition to when they’re tweeting about it.

A few quick notes on methodology: here’s an example of the data from the Twitter API. I used “burgers” and “tacos” because the singular comes up with too many tweets related to Taco Bell, Burger King, etc. The singular of “pizza” may have pulled down a lot of Pizza Hut-related tweets, unfortunately, but people really don’t talk about multiple pizzas too often.

Lastly, a lot of non-technical people I talk to are amazed when I explain that it only takes a few lines of code to get data from the Twitter API. For the most part, getting the data really isn’t that hard — the harder part is figuring out what to do with it. While it may read like gibberish to most folks, here are the few lines of PHP code that can process thousands of tweets: