Brazilian Heavy Metal: An Exploratory Data Analysis using NLP and LDA
By: Flávio Clésio
Tags: Data Science, Python, Machine Learning, Exploratory Data Analysis, Data Visualization

Brazilian Heavy Metal: An Exploratory Data Analysis using NLP and LDA

Let’s see how to get there

Motivation

In most of my time, I get used to experimenting some NLP techniques and I noticed that even with the plethora of resources available, it’s very hard to find some NLP tech stuff attached with Data Analysis, i.e. related to general knowledge over the data like Text Mining.

It’s very cool to have a lot of scripts, applied blog posts, repositories in Github with code, but at least for me the analysis it’s where the technique shines most because anyone it’s able to write a script but only a few ones can extract knowledge of the data.

The idea here it’s getting the lyrics of two bands that I like and check their literary characteristics and try to find some relation or distinction between them.

For very deep and technical posts about NLP, LDA and so on, feel free to jump directly to the end of this post and choose a lot of very nice references about these topics.

And this is what this post is about, and was deeply inspired for a great job of the Machine Learning Plus.

Why Angra and Sepultura?

Heavy Metal it’s one of the most borderless music styles in the world and I would like to show two of the most iconic bands of my country and their literary characteristics in a simple way using Python, LDA, NLP and some imagination (you will see during the “interpretation” of topics.

About the Bands

Sepultura

Sepultura is a Brazilian heavy metal band from Belo Horizonte. Formed in 1984 by brothers Max and Igor Cavalera, the band was a major force in the groove metal, thrash metal, and death metal genres during the late 1980s and early 1990s. Sepultura has also been credited as one of the second wave of thrash metal acts from the late 1980s and early-to-mid 1990s.

Sepultura Oficial Website — Sepultura in Spotify

Angra

Angra is a Brazilian heavy metal band formed in 1991 that has gone through some line-up changes since its foundation. Led by Rafael Bittencourt, the band has gained a degree of popularity in Japan and Europe.

Angra Oficial Website — Angra in Spotify

Questions

Some personal questions that I always had about these bands and I’ll try to answer with this notebook is:

1) What're the literary characteristics for Angra and Sepultura?

2) Which type of thematics did they talk about?

3) Who has more diversity in their topics?

Some limitations

NLP it’s still an unsolved problem even with all over promising about it. This two anthological pieces by Yoav Goldberg and The Gradient put that in perspective;

The creative process even with some patterns it’s a very complex that can involve a lot of poetic licenses. In this video, Rafael Bittencourt explains the whole process to compose a single lyric for the new album, and in this video, Max Cavalera speaks about the creative process behind the classic album “Roots” from 1996.

Applied techniques

Natural Language Processing

Natural language processing (NLP) is a subfield of computer science, information engineering, and artificial intelligence concerned with the interactions between computers and human (natural) languages, in particular how to program computers to process and analyze large amounts of natural language data.

Topic Modeling

In machine learning and natural language processing, a Topic Model is a type of statistical model for discovering the abstract “topics” that occur in a collection of documents. Topic modeling is a frequently used text-mining tool for the discovery of hidden semantic structures in a text body. Topic models are also referred to as probabilistic topic models, which refers to statistical algorithms for discovering the latent semantic structures of an extensive text body.

Latent Dirichlet Allocation

In natural language processing, Latent Dirichlet allocation (LDA) is a generative statistical model that allows sets of observations to be explained by unobserved groups that explain why some parts of the data are similar. For example, if observations are words collected into documents, it posits that each document is a mixture of a small number of topics and that each word’s presence is attributable to one of the document’s topics. LDA is an example of a topic model.

Code & Data

All code, datasets, and images are stored in this Github repo.

Data extraction and load

To extract the lyrics I used PyLyrics library using this script. Important: This library doesn't have any update/bug fix since last year. Below we can import some libraries and start a small pre-processing over our data.

The wrapper fetched 325 songs bringing the artist, lyric, and album.

One of the main challenges it’s that these bands usually write songs in multi-language (EN and PT-BR). For a matter of simplicity, we’ll concentrate only on the EN language.

To filter the PT-BR songs I’ll use textblob library that uses the Google API to check the language. The main caveat it's if you re-run a lot of times maybe you receive the code HTTP Error 429: Too Many Requests .

Here we can see that from 325 lyrics 38% is from Angra and 62% is from Sepultura. Angra has 96% (119) of all lyrics in EN and Sepultura have 96% (194) of all lyrics in EN.

The most remarkable song in PT-BR from Angra (IMHO) it’s Caça e Caçador what was a song from the album Hunters and Pray. In the Temple of Shadows album the song Late Redemption it’s a good piece in EN/PT-BR.

Sepultura has some songs in PT-BR like Filhos do Mundo from Bestial Devastation, Prenuncio from Against and A Hora E A Vez Do Cabelo Nascer from the Beneath the Remains album that is a cover song from Mutantes. The most remarkable one in PT-BR it’s the Policia song.

With all PT-BR lyrics removed let’s perform a quick check in all albums of these bands.

In a first look, considering our dataframe, we can see the first difference between these two bands that Sepultura has a larger discography and more songs per album.

This can be explained with the fact that even both bands faced a hiatus in the time of that they changed their main singers (Andre Matos and Edu Falaschi in Angra and Max Cavalera by Sepultura) Sepultura released 8 albums after their break (all of them with Derrick Green) and in meanwhile Angra released 6; and Sepultura it’s a more prolific band.

Let’s keep that information in mind because maybe it can be explained in the second moment in this analysis.

Let’s check the average songs per album.

As we visually inspected Sepultura not even have more albums, but have more songs per album.

To start our analysis one important aspect of Text Analysis it’s the data pre-processing. Here we’re literally can screw all analysis because the Pre-Processing it’s responsible to remove all noise of the data and normalize all data to get meaningful results. Kavita Ganesan made a great analysis of this topic and I strongly recommend the read.

The first step will be to remove all English stopwords of all lyrics.

PS: Personally I don’t like to use off-the-shelf stopwords list because every domain demands specific words subsets to define if some word it’s important or not. But let’s keep that way for a matter of simplicity. This nice text of Martina Pugliese explains it in detail. In terms of implementation this article of ML Whiz probably its the best resource available on the internet.

After the stopwords removal, let’s perform a quick visual check on the most frequent words used by these two bands. In other words: What’s most used words in their compositions?