logo
ResearchBunny Logo
A city-wide examination of fine-grained human emotions through social media analysis

Computer Science

A city-wide examination of fine-grained human emotions through social media analysis

P. Siriaraya, Y. Zhang, et al.

Using OpenStreetMap and Twitter, this study maps fine-grained human emotions across San Francisco and London. Neural network classifiers detect emotions in tweets and link them to key OpenStreetMap locations, revealing how days, places and POI neighborhoods shape city-wide emotional expression. This research was conducted by Panote Siriaraya, Yihong Zhang, Yukiko Kawai, Peter Jeszenszky, Adam Jatowt.... show more
Introduction

This study investigates whether social media data, specifically geotagged tweets, can portray fine-grained human emotions at a city-wide yet spatially detailed level. While prior research often mapped broad sentiment polarity (positive/negative) at coarse resolutions (country/state/city), this work aims to analyze seven specific emotions (Anger, Anticipation, Disgust, Fear, Trust, Joy, Sadness) and contextualize them at fine spatial granularity (Point of Interest, POI). The purpose is to: (1) develop and evaluate classifiers to detect fine-grained emotions in tweets; (2) visualize temporal characteristics of emotions across a year; and (3) assess how different place types (from OpenStreetMap POIs) influence emotional expression in San Francisco and London. This approach seeks to provide actionable insights for urban analysis beyond coarse sentiment mapping, enabling better understanding of how time and specific locations relate to emotional expression.

Literature Review

Prior works have used social media (Twitter, Flickr) to analyze macro-scale sentiment and happiness, often correlating sentiment with urban metrics (transport access, jobs) and applying insights to applications such as safe route recommendation or crime prediction. Recent efforts explored specific emotions (e.g., fear, anger) using geotagged tweets, visualizing emotional dimensions worldwide and examining emotional responses to events (terror attacks in London and Paris). However, most studies: (a) use coarse spatial units (country/state/city), (b) focus on polarity rather than specific emotions, and (c) lack POI-level analyses. Evidence suggests city features (green spaces, landmarks, transport hubs) affect emotional responses, motivating finer-resolution studies of urban emotions. This paper contributes by analyzing seven specific emotions at POI-level categories, linking emotion expression to place types.

Methodology

Data Collection: Two English-speaking, dense urban cities were selected: San Francisco (USA) and Greater London (UK), due to richer open data footprints and reliable OSM coverage. Spatial data were sourced from OpenStreetMap (OSM) using tags from nodes, ways, and relations. POIs were identified via relevant tags (e.g., leisure, shop, amenity). Tag redundancy was reduced by merging variants (e.g., British/American English, singular/plural), and POI types were categorized using the Ordnance Survey classification scheme (9 categories: Hotel & Restaurants, Commercial Services, Attractions, Sports & Entertainment, Education & Health, Public Infrastructure, Manufacturing & Production, Retail, Transportation) plus Residential and Office.

  • OSM summary: Greater London: 4,823,654 elements; 236,482 POIs; 1,425 unique POI types. San Francisco: 3,211,795 elements; 21,816 POIs; 527 unique POI types. Notable differences included higher Residential share in London (57.52%) vs San Francisco (24.52%), more food-serving venues in San Francisco (26.70% vs 18.75%), and more Attractions in San Francisco (23.48% vs 16.59%).

Tweets: Geotagged tweets were collected via Twitter Streaming API using bounding boxes (SF: SE (37.7020,-122.3362), NW (37.8355,-122.5422); London: SE (51.2765, 0.3571), NW (51.686,-0.5713)) from 09/01/2016 to 08/28/2017. Metadata included user ID, coordinates, timestamp, and language. Approximately 0.96M tweets (SF) and 2.18M (London) were collected. Pre-processing removed auto-generated posts (e.g., Foursquare check-ins, automated weather reports) via regex, leaving 0.39M tweets (SF; ~65k users) and 1.57M tweets (London; ~180k users).

Emotion Detection: Target emotions followed Plutchik’s wheel (Anger, Anticipation, Disgust, Fear, Joy, Sadness, Surprise, Trust). Eight binary classifiers (one per emotion) were trained and evaluated using the SemEval 2017/2018 dataset (~11,700 labeled tweets, 2016–2017). Six modeling approaches were compared via 10-fold cross-validation using F-score:

  1. SVM+GloVe: tweets vectorized with 200-d GloVe (trained on 22B tweets); linear SVM (C=1, hinge loss) on mean embeddings.
  2. SVM+Lexicon: features from 25 lexicons (NRC-10 word and hash emotion lexicons, SentiWord, emoticons, etc.).
  3. SVM+Lexicon+GloVe: combined lexicon features and GloVe embeddings.
  4. NN+GloVe: 2-layer dense NN (200 nodes); sigmoid output.
  5. LSTM+GloVe: 2-layer LSTM (200 nodes; dropout=0.4); RMSprop; binary cross-entropy; sigmoid output.
  6. Hybrid+Lexicon+GloVe: adapted hybrid NN (prior bot detection architecture) taking both lexicon features and embeddings (architecture in S1 Fig). Evaluation indicated: Hybrid+Lexicon+GloVe best for Anger and Anticipation; LSTM+GloVe best for Fear, Joy, Sadness, Surprise, Trust; SVM+Lexicon+GloVe best for Disgust. Surprise was excluded from downstream analysis due to lower performance (best F-score ~0.61).

Temporal Aggregation: For each user per day, emotion ratio was computed: fraction of that user’s tweets classified positive for a given emotion. Tukey’s fences (K=1.5) filtered low-range outlier days with too few tweets to mitigate bias. Daily emotion values were averaged across users; heatmaps used z-scores for comparability.

Spatial Contextualization at POIs: Tweets were associated with POIs if within a POI-specific radius, determined by distance to nearest non-tagged building or tagged POI (computed over 0.44M London and 0.28M SF locations). Isolated POIs used citywide average distances (SF ~14 m; London ~9 m); isolation threshold by Tukey’s fences (SF ~51.5 m; London ~50.0 m). Distances used the Haversine formula. Resulting matched POIs with nearby tweets: SF 4,674 (21.42%); London 26,740 (11.31%). Analysis used non-parametric tests due to heavy-tailed distributions: Kruskal-Wallis for category differences and Bonferroni-corrected Dunn post-hoc tests.

POI Neighborhood Effects: For each tweet (positive vs not for each emotion), counts of nearby venues by category were computed within radii (SF: 10 m, 30 m, 50 m). Mann-Whitney tests with Bonferroni correction compared category counts between positive and non-positive tweets to infer which categories were more/less prevalent around tweets expressing specific emotions.

Key Findings
  • Classifier selection: Hybrid+Lexicon+GloVe performed best for Anger and Anticipation; LSTM+GloVe for Fear, Joy, Sadness, Trust; SVM+Lexicon+GloVe for Disgust. Surprise was excluded due to lower performance.
  • Emotion prevalence: San Francisco—Anger 3.1%, Disgust 5.5%, Anticipation 5.8%, Joy 49.2%, Sadness 4.1%, Fear 3.7%, Trust 6.1%. London—Anger 3.8%, Disgust 5.9%, Anticipation 4.8%, Joy 49.5%, Sadness 4.6%, Fear 2.8%, Trust 4.0%.
  • Temporal spikes (San Francisco): Women’s March/Presidential Inauguration (Jan 20–22, 2017) associated with high Anticipation (01/21: 0.106 vs daily avg ~0.07), and high Anger (01/22: 0.069 vs ~0.03), Disgust (01/22: 0.097 vs ~0.058), Sadness (01/22: 0.081 vs ~0.044). Berkeley protests (08/26/2017) showed the second highest Anger (0.615) and Disgust (0.092). New Year’s Eve showed high Joy (0.612 vs ~0.502).
  • Temporal spikes (London): Westminster attack (03/23/2017) showed highest Fear (0.097 vs ~0.0275) and highest Sadness (0.122 vs ~0.04). London Bridge attack (06/03/2017) produced elevated Fear in following days (06/04: 0.067; 06/05: 0.053) and Sadness (06/04: 0.084). New Year’s showed high Joy (0.636 vs ~0.509); Valentine’s Day showed the second highest Joy (0.581). UK General Election (06/08/2017) showed highest Trust (0.0635 vs ~0.041) and Anticipation (0.092 vs ~0.056).
  • Day-of-week differences: San Francisco—significant differences in Anger, Anticipation, Sadness (p<0.01); Anger higher midweek (e.g., Wednesday median ~0.037), lower on weekends; Anticipation lowest Sunday (median ~0.0596) vs higher Fridays (~0.0722); Sadness lower weekends (Saturday/Sunday ~0.038) vs weekdays (e.g., Monday ~0.044). London—significant differences in Anger, Anticipation, Joy, Sadness, Fear, Trust (p<0.01); Anger, Sadness, Fear lowest Sundays (medians: Anger 0.034; Sadness 0.038; Fear 0.023), higher on weekdays (e.g., Tuesday Anger 0.04; Wednesday Sadness 0.046; Fear 0.028); Anticipation lowest Sunday (median 0.045 vs ~0.055 others); Joy higher Sunday (median 0.513 vs ~0.508 others).
  • POI-specific emotion patterns (top tags): Tweets near hospitals, dentists, and doctor offices exhibited high Fear and Sadness; water-related activity venues (swimming pools, sailing ports, coastlines, boat ramps) showed high Joy; transport-related locations (bus stops, bridges, train stations) showed higher Anger and Disgust.
  • Category-level differences (Kruskal-Wallis with Dunn post-hoc): San Francisco—more Anger near Retail and Office than Education & Health; more Joy near Hotel & Restaurant than Transportation; more Fear near Sports & Entertainment (and Attractions) than Hotel & Restaurant, Commercial Services, Transportation. London—more Anger near Sports & Entertainment, Hotel & Restaurant, Transportation than near Education & Health, Residential, Retail; Disgust higher near most non-Residential categories than Residential; Joy higher near Hotel & Restaurant than Transportation; Fear higher near Attractions and Sports & Entertainment than many other categories; many emotions significantly lower in Residential areas.
  • Neighborhood effects (Mann-Whitney with Bonferroni; SF): Joy tweets had significantly more Hotel & Restaurant, Commercial Services, and Sports & Entertainment within close vicinities and fewer Offices; Anger and Sadness tweets had significantly more Offices across distances; Trust tweets had more Public Infrastructure within 10–20 m (effect diminished by 30 m).
Discussion

The findings demonstrate that fine-grained emotions can be reliably inferred from geotagged tweets and meaningfully contextualized using POI data at city scale. Temporal analyses captured known event-driven emotional spikes (terror incidents, protests, holidays), indicating sensitivity to societal events and validating the approach against prior observations. Weekly patterns—higher positive emotion on weekends, higher negative emotions midweek—align with intuitive behavior and previous social media studies. Spatial analyses reveal consistent relationships between place types and emotion: transport hubs and sports venues related to elevated negative emotions (e.g., Anger, Disgust, Fear, Sadness), while food/tourism-related areas (Hotel & Restaurant, Attractions, water recreation) associate with Joy and Trust. Residential areas showed generally lower emotional intensity compared to other categories, suggesting differing social dynamics. These results address the research question by showing that both time and specific urban places influence the expression of distinct emotions, extending beyond coarse polarity measures and enabling POI-level insights applicable to urban planning, tourism, and public well-being monitoring.

Conclusion

This work presents a city-wide, fine-grained emotion analysis framework combining Twitter geotagged data with OSM-derived POIs for San Francisco and London. Seven emotions were detected using evaluated neural and hybrid models, enabling temporal visualization and spatial contextualization at POI level. Key contributions include: (1) demonstrating POI-level emotion mapping across multiple fine-grained emotions; (2) evidencing temporal spikes aligned with major events; and (3) uncovering systematic associations between place categories and emotional expression. Future research directions include drilling down into specific subcategories (e.g., restaurant types, recreational facilities), exploring buffering effects of certain places on negative emotions during adverse events, and extending to digital archiving of collective emotional responses with higher spatial-temporal resolution.

Limitations

Generalizability is limited by the focus on two English-speaking urban cities and reliance on geotagged tweets, which have demographic and selection biases (e.g., younger, more educated users; potential female overrepresentation in urban areas; differences in location-sharing demographics). Social media posts may overrepresent emotionally salient events, and absence of posts can bias measures. Automated emotion classification, while validated, remains imperfect and may introduce errors. The approach depends on the availability and quality of volunteered geographic information (OSM) and social media footprints; sparsely populated or rural areas often have fewer POIs and fewer geotagged tweets, reducing feasibility and accuracy of fine-grained analyses. These constraints should be considered when interpreting and generalizing results.

Listen, Learn & Level Up
Over 10,000 hours of research content in 25+ fields, available in 12+ languages.
No more digging through PDFs, just hit play and absorb the world's latest research in your language, on your time.
listen to research audio papers with researchbunny