OBNOXIOUS TOPIC MODEL LABEL FAVORS
Today, I tried to see if a computer could “guess” some of the different things that hip hop is about.  This is a shallower question than you think -- I’m  not trying to get my laptop to understand anything about the political or cultural climate in which hip hop exists.  I just wanted to see if it could comb through my hip corpus and give me a reasonable summary of what ideas hip hop songs tend to touch on.
To do this, I used something called a topic model.  Topic models are mostly used to extract recurring ideas out of larger datasets -- say, a massive corpus of Tweets or news articles.  They compare the distributions of words in each document to determine words that are disproportionately important, and then are able to group similar disproportionately important words together.  The basic idea is that, when you look at the words that the algorithm clusters together, you’ll be able to get a rough idea of what the entire collection of documents is “about”.  Importantly, this model acknowledges that one document (or set of documents) can be “about” multiple things (e.g., the way this blog is about both NLP and hip hop). Â
Topic models are unsupervised learning algorithms, so they output unlabeled clusters of data.  As a result, initially reading the output of a topic model is unintuitive: the output won’t say “love is one topic of hip hop songs”, but will instead give you a cluster of words that represent or connect to a topic (e.g., love, oh, girl, come, back, life, need, good, want).  Some of the clusters will be repeated and/or nonsense.  Others will be insightful enough that you, as a human, can find a common thread between each word in the cluster.  That thread is your topic.  Whether or not two different people are able to see the same common thread across a cluster is a good indication of how the topic model is doing. Â
Here are some reasonable clusters that the model spit out:
Life and death: man (0.0076), tech (0.0056), come (0.0051), gonna (0.0047), die (0.0047), god (0.0041), would (0.0040), world (0.0040), back (0.0035), time (0.0033), got (0.0032), said (0.0031), say (0.0030), better (0.0030), stop (0.0029), still (0.0029), live (0.0028), around (0.0028)
Raps about rapping: rap (0.0067), mc (0.0061), shit (0.0060), mic (0.0057), rhyme (0.0054), rhymes (0.0053), em (0.0053), black (0.0051), time (0.0048), check (0.0042), rock (0.0037), kid (0.0035), style (0.0035), hip (0.0034), new (0.0034), hop (0.0032), never (0.0032), back (0.0031)
Love-ish: love (0.0500), oh (0.0192), baby (0.0182), yeah (0.0157), make (0.0130), come (0.0128), feel (0.0124), time (0.0117), say (0.0091), need (0.0085), good (0.0084), gonna (0.0083), boy (0.0065), world (0.0064), take (0.0063), think (0.0062)
Songs you won’t play around your parents: shit (0.0130), fuck (0.0110), nigga (0.0109), ass (0.0104), wit (0.0087), gotta (0.0086), make (0.0082), bitch (0.0072), da (0.0064), man (0.0062), say (0.0060), niggas (0.0057), aint (0.0054), come (0.0051), take (0.0049), never (0.0047), high (0.0044), hoes (0.0043)
These results come from asking the topic model to produce 50 clusters, and run through the dataset 15 times (each run through will improve the results slightly). Â I told the model to ignore stopwords (like the) and also a set of specialized hip hop stopwords, as determined by the LLR and weight algorithms I posted about earlier. Â
We can also use topics to compare subsets of the data.  For example, we can run the topic modeler on only female artists in the dataset (just so you know how I’m doing here, only about 10% of the artists in my dataset are female :/).  Notably missing were the raps about rapping and the songs you won’t play around your parents topics, but there’s a very good chance that’s due to a sampling error (only 10% of the artists in my dataset are female).
Run the world imma (0.0158), life (0.0140), change (0.0130), shit (0.0111), back (0.0098), make (0.0094), money (0.0079), love (0.0078), time (0.0072), never (0.0072), need (0.0068), work (0.0062), big (0.0061), bitch (0.0059), new (0.0057), world (0.0055),
Who run the world: girls queen (0.0115), baby (0.0104), come (0.0072), oh (0.0066), girls (0.0062), time (0.0059), make, (0.0059), take (0.0046), keep (0.0044), give (0.0043), head (0.0043), never (0.0042), yeah (0.0042), mean (0.0038), say (0.0037),
Great night out love (0.0220), night (0.0197), right (0.0194), feel (0.0193), yeah (0.0188), away (0.0158), life (0.0152), oh (0.0141), give (0.0117), nobody (0.0116), need (0.0110), good (0.0109), club (0.0108), boy (0.0107), crazy (0.0103), looking (0.0099), tell (0.0098), tonight (0.0098), say (0.0094)
Just straight up sexytimes nigga (0.0185), ass (0.0146), dick (0.0123), hoes (0.0108), man (0.0100), back (0.0094), niggas (0.0084), pussy (0.0081), tha (0.0074), fuck (0.0070), baddest (0.0070), bitches (0.0067), make (0.0054), bitch (0.0051), say (0.0046), baby (0.0045), tongue (0.0045), damn (0.0045), girl (0.0042)
If you want to play around with the topic model, it’s available on github. (Full disclosure: the code from this is slightly modified from a long-ago course assignment -- it’s great to play with, but there are better, much more sophisticated tools available, like MALLET.)













