At the D-Lab, we work hard to provide the campus community with access to the learning resources they need. We consult and teach workshops on research design, data analysis, coding, and much more. We also like to have fun.

Last semester, D-Lab Research Associate Dillon Niederhut created a Twitter bot, named @BerkeleyMood, designed to determine how the city is feeling. It works by counting words and emoticons that are associated with one of five pre-defined emotional states—happy, sad, angry, loving, afraid—and choosing the most frequent emotion. It does this every hour. If the city's mood has changed, @BerkeleyMood tweets about it. Dillon's written the code for this bot in Python, which is available on GitHub.

When Dillon analyzed the data he had collected over the course of several months in R, he found some interesting patterns in how mood changes throughout the day.

For example, the happy tweets in Berkeley are most frequent around lunchtime, while most sad tweets tend to occur around 4 AM.

This is an example of a fun project you can do with some basic programming in Python. The D-Lab offers workshops on APIs, bot-building, and text analysis, all of which can be used to expand on this project or create one of your own. We're planning to offer our Twitter bot-building workshop again in the spring. Until then, take a look at our materials on GitHub.

For those interested in learning Python, we'll be offering a multi-day workshop series in January, before the start of classes. This series will guide students from the basics to interacting with the file system, working with APIs, analyzing data, and more.

 

Author: 

Juan Shishido

Juan was a member of the D-Lab services team and a masters student at the School of Information until 2016. He is interested in data literacy and access and supported workshop development and instruction at the D-Lab toward that end. His interests include information visualization, machine learning, causal inference, and experimental design.