This repository contains code and data for analyzing Reddit comments across multiple cities using LLMs (Llama 3.2 and Qwen 2.5) for classification and mitigation.
Run the following script to collect Reddit data:
python scripts/get_reddit_data.pyNote: You'll need to:
- Replace
CLIENT_ID,CLIENT_SECRET, andUSER_AGENTwith your Reddit API credentials - Specify your target subreddit name
- The script outputs 3 CSVs in
data/<city>/reddit/:all_comments.csv(not included due to identifiable information)filtered_comments.csv(not included due to identifiable information)statistics.csv(included)
After data collection, run:
python scripts/random_reddit_sample.pyThis generates a random set of 50 Reddit comments per city.
The deidentified dataset (500 comments total, 50 from each of 10 cities) is available at:
output/sampled_reddit_comments_by_city_deidentified.csv
To generate this yourself:
python scripts/deidentify_comments.pyDownload the following models from HuggingFace:
The annotation data is available in:
- Raw scores:
annotation/raw_scores.csv - Processed outputs:
To generate these yourself:
python scripts/annotator_agreement.pyThe classified comments are available in:
To run the classification yourself:
python scripts/llama_3_2_classify.py
python scripts/qwen_3_2_classify.pyThe mitigated comments are available in:
To run the mitigation yourself:
python scripts/llama_3_2_mitigate.py
python scripts/qwen_3_2_mitigate.pyAll statistics and charts are available in the output/charts/ directory.
To generate these yourself:
python scripts/calculate_intercoder_reliability.py