<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Andres Gonzalez on Medium]]></title>
        <description><![CDATA[Stories by Andres Gonzalez on Medium]]></description>
        <link>https://medium.com/@gonzalez_afc?source=rss-dcfd3d0757fa------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*KoIPEr0WwaM1eDLM</url>
            <title>Stories by Andres Gonzalez on Medium</title>
            <link>https://medium.com/@gonzalez_afc?source=rss-dcfd3d0757fa------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 17:08:32 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gonzalez_afc/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Sentiment Analysis of the The Smiths: Quintessentially English, this iconic band dominated the…]]></title>
            <link>https://medium.com/@gonzalez_afc/sentiment-analysis-of-the-the-smiths-a-quintessential-english-band-that-ruled-the-80s-173266b1d697?source=rss-dcfd3d0757fa------2</link>
            <guid isPermaLink="false">https://medium.com/p/173266b1d697</guid>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[music]]></category>
            <category><![CDATA[rock-and-roll]]></category>
            <dc:creator><![CDATA[Andres Gonzalez]]></dc:creator>
            <pubDate>Sun, 08 Aug 2021 00:38:15 GMT</pubDate>
            <atom:updated>2023-06-15T18:49:40.390Z</atom:updated>
            <content:encoded><![CDATA[<h3>Sentiment Analysis of The Smiths: Quintessentially English, this iconic band dominated the 1980s music scene.</h3><p>Using Spotify’s API’s and Genius API’s music attributes to analyze The Smiths discography</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9__juoJmwIw0SZu7" /><figcaption>Photo by <a href="https://unsplash.com/@neonbrand?utm_source=medium&amp;utm_medium=referral">NeONBRAND</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Spotify is the world’s biggest music streaming platform by number of subscribers. It is a digital music streaming service that gives you access to millions of songs, podcasts and videos from artists all over the world, using Spotify’s desktop or mobile app, tablet, TVs, cars, watches and more.</p><p>I’ve been using Spotify Premium for years and it has never failed to disappoint me on their recommendation algorithm to suggest new artists or songs based of what I’ve listened too previously. Music has always been a huge part of my life as it is a way of expressing our feeling as well as emotions. Over the years I discovered different styles or types of music, some of which I grew up listening to artists such as Snoop Dogg, Dr. Dre, The Beatles, Radiohead, and many others. Nevertheless, the one band that speak to me the most when growing up and even today is The Smiths. Hence, I wanted to apply Data Science techniques and use the spotifyr package to retrieve their entire discography from Spotify’s Web API, along with audio features to analyze their albums and lyrical sentimements. All of the code can be found <a href="https://github.com/OKcomputer626/MyProjects.git">here</a>.</p><p><strong>Introduction</strong></p><p>The Smiths, an English rock band, emerged from Manchester in 1982, featuring the remarkable lineup of vocalist Morrissey, guitarist Johnny Marr, bassist Andy Rourke, and drummer Mike Joyce. Their combined talents led to an impressive and prolific output of exceptional music in a brief period, carving a distinctive niche in the music world. As outsiders, they resonated with a similar audience, creating anthems for those who felt misunderstood or marginalized. Their profound impact on fans’ lives, including my own, is a testament to their enduring legacy. With a rich discography that still captivates listeners, The Smiths will forever be regarded as one of the greatest bands in music history.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Aouai7DDxyf4DsSkzGM9aA.jpeg" /><figcaption><a href="https://media.gq.com/photos/5e20b709fa68860008e4f6a6/16:9/w_2560%2Cc_limit/SIP-the-smiths-01.jpg">https://media.gq.com/photos/5e20b709fa68860008e4f6a6/16:9/w_2560%2Cc_limit/SIP-the-smiths-01.jpg</a></figcaption></figure><h3>Data Dictionary</h3><p>In this section we are going to describe some audio features and metrics in the data set:</p><ul><li><strong>Danceability:</strong> Describes how suitable a track is for dancing based on a combination of musical elements including tempo, rhythm stability, beat strength, and overall regularity.</li><li><strong>Valence: </strong>Describes the musical positiveness conveyed by a track. Tracks with high valence sound more positive (e.g. happy, cheerful, euphoric), while tracks with low valence sound more negative (e.g. sad, depressed, angry).</li><li><strong>Energy:</strong> Represents a perceptual measure of intensity and activity. Typically, energetic tracks feel fast, loud, and noisy. For example, death metal has high energy, while a Bach prelude scores low on the scale.</li><li><strong>Tempo: </strong>The overall estimated tempo of a track in beats per minute (BPM). In musical terminology, tempo is the speed or pace of a given piece, and derives directly from the average beat duration.</li><li><strong>Loudness: </strong>The overall loudness of a track in decibels (dB). Loudness values are averaged across the entire track and are useful for comparing relative loudness of tracks.</li><li><strong>Speechiness: </strong>This detects the presence of spoken words in a track. The more exclusively speech-like the recording (e.g. talk show, audio book, poetry), the closer to 1.0 the attribute value.</li><li><strong>Instrumentalness: </strong>Predicts whether a track contains no vocals. “Ooh” and “aah” sounds are treated as instrumental in this context. Rap or spoken word tracks are clearly “vocal”.</li><li><strong>Liveness: </strong>Detects the presence of an audience in the recording. Higher liveness values represent an increased probability that the track was performed live.</li><li><strong>Acousticness:</strong> A confidence measure from 0.0 to 1.0 of whether the track is acoustic.</li><li><strong>Key:</strong> The estimated overall key of the track. Integers map to pitches using standard <a href="https://en.wikipedia.org/wiki/Pitch_class">Pitch Class notation</a> . E.g. 0 = C, 1 = C♯/D♭, 2 = D, and so on.</li><li><strong>Mode:</strong> Indicates the modality (major or minor) of a track, the type of scale from which its melodic content is derived. Major is represented by 1 and minor is 0.</li><li><strong>Duration:</strong> The duration of the track in milliseconds.</li><li><strong>Time Signature:</strong> An estimated overall time signature of a track. The time signature (meter) is a notational convention to specify how many beats are in each bar (or measure).</li></ul><p>we can use the function get_artist_audio_features() from the spotifyr package in order to retrieve the popularity and audio features for every song and album for a given artist on Spotify.</p><pre># Call the &#39;get_spotify_access_token()&#39; function to obtain an access token for the Spotify API<br># Store the access token in the &#39;access_token&#39; variable<br>access_token &lt;- get_spotify_access_token()<br><br># Store the retrieved audio features in the variable &#39;smiths&#39;<br>smiths &lt;- get_artist_audio_features(&#39;the smiths&#39;)</pre><p>Let’s determine the most common keys</p><pre># Create a bar chart to visualize the key mode distribution across albums<br>smiths_filtered %&gt;%<br>  ggplot(aes(x = key_mode, y = n)) +<br>  geom_chicklet(aes(fill = album_name), width = 0.75) +<br>  geom_text(aes(label = n),<br>            size = 3,<br>            color = &quot;white&quot;,<br>            position = position_stack(vjust = 0.5)) +<br>  labs(title = &quot;Key Mode Distribution of &lt;span style = &#39;color:#06A6DA&#39;&gt;The Smiths&lt;/span&gt; Across Albums&quot;) +<br>  scale_y_continuous(breaks = seq(0,10, by = 2)) +<br>  scale_fill_manual(values = c(&quot;#AD9CB7&quot;,&quot;#013706&quot;, &quot;#B83868&quot;, &quot;#AE9946&quot;),<br>                    breaks = c(&quot;The Smiths&quot;,&quot;Meat Is Murder&quot;, &quot;The Queen Is Dead&quot;, &quot;Strangeways, Here We Come&quot;)) +<br>  theme_minimal() +<br>  theme(<br>    text = element_text(family = &quot;lato&quot;),<br>    plot.title = element_markdown(size = 20, face = &quot;bold&quot;, hjust = 0.5),<br>    plot.title.position = &quot;plot&quot;,<br>    axis.text.x = element_text(angle = 45, hjust = 1),<br>    axis.title = element_blank(),<br>    legend.position = &quot;bottom&quot;,<br>    legend.title = element_blank()<br>  )</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fJTnPgf3w0cskThg-zLkMQ.png" /></figure><p><strong>Boxplots</strong></p><p>Let’s visualize the distribution of the following audio features: acousticness, danceability, energy, instrumentalness, liveness and valence (ranges between 0.0 to 1.0). We can start with the boxplots, in order to represent the distribution of data over a continuous interval. A boxplot is a method for graphically depicting groups of numerical data through their quartiles.</p><pre># Reshape the data<br>smiths_filtered %&gt;%<br>  pivot_longer(cols = all_of(columns), names_to = &quot;features&quot;, values_to = &quot;count&quot;) %&gt;%<br>  group_by(features) %&gt;%<br>  mutate(outlier = ifelse(features == &quot;acousticness&quot; &amp; find_outlier(count), track_name, NA)) %&gt;%<br>  ggplot(aes(x = features, y = count, fill = features)) +<br>  geom_boxplot(show.legend = FALSE, color = &quot;black&quot;) +<br>  geom_text_repel(aes(label = outlier), color = &quot;black&quot;, size = 3, nudge_y = 0.1, box.padding = 0.5) +<br>  labs(<br>    title = &quot;Distribution of Audio Feature Values &lt;span style= &#39;font-size:24pt; font-family:bodoni; color:#EE2E34;&#39;&gt;THE SMITHS&lt;/span&gt; Songs&quot;,<br>    x = &quot;Audio Features&quot;<br>  ) +<br>  scale_x_discrete(labels = c(&quot;Acousticness&quot;, &quot;Danceability&quot;, &quot;Energy&quot;, &quot;Instrumentalness&quot;)) +<br>  scale_y_continuous(limits = c(0,1), breaks = seq(0,1, by = 0.2)) +<br>  scale_fill_paletteer_d(&quot;ggthemes::gdoc&quot;) +<br>  theme_minimal() +<br>  theme(<br>    text = element_text(family = &quot;lato&quot;),<br>    plot.title = element_markdown(size = 18, face = &quot;bold&quot;),<br>    plot.title.position = &quot;plot&quot;,<br>    axis.title.y = element_blank()<br>  )</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ghVVpp7lPZ31_AhAF9IMMQ.png" /><figcaption>Boxplot of The Smiths song Features</figcaption></figure><p>In this observation, we can see that the instrumentalness metric has many outliers which we need to pay attention to the signs of skewness. It seems that this feature has a right skewed distribution. A few outliers were identified in the plot, and it was recommended to label them with their respective track names. One such example is “Unhappy Birthday” from the album “Strangeways, Here We Come,” which notably stands out for its acousticness feature.</p><h3>Exploring Albums and Songs Analysis</h3><p>Now, let’s examine the same parameters, but on an album-by-album basis. We’ll utilize the ggridges package, which creates ridgeline plots. These partially overlapping line plots resemble a mountain range and have also been referred to as “joyplots”. We’ll start by analyzing the acousticness, danceability, and energy features, and sort the labels based on each album’s release date.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dNdMvF0pPsSdH29mkyBzYg.png" /><figcaption>Valence Patterns in The Smiths Classic Albums</figcaption></figure><p>In this scatterplot below, we see the tracks from The Smiths albums categorized by their emotional qualities. It appears that a majority of their songs are uplifting and energetic, while only a few are melancholic and calm. This observation reveals that The Smiths managed to create a well-balanced mix of both happy and depressing songs throughout their discography.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2xflJ3qXjaaE7Zz7CsiFIg.png" /><figcaption>Emotional Landscape of The Smiths Songs Across Albums</figcaption></figure><p>Fascinating! I frequently believed that the majority of their songs exude high energy (indeed, most of their tracks have an incredible vibe!).</p><p>Below is a table chart, created using the gt package, showcasing the audio features for each album obtained from the spotifyr package. Notably, the longest duration album in The Smiths discography is their 1984 debut album, “The Smiths.” If you’re seeking an energetic listening experience, we highly recommend “Strangeways, Here We Come” as the album features a high concentration of tracks with energetic characteristics.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0LAvzrDjrmPQWq30VsfE8g.png" /></figure><p><strong>Genius Lyrics</strong></p><p>In 1986, The Smiths released their third studio album, which is widely regarded as a masterpiece. This flawless album solidified their status as one of the world’s greatest bands. It’s definitely among my all-time favorites. Interestingly, the album features a mix of both deeply energetic and uplifting songs.</p><p>Lastly, we will be using Genius Lyrics to retrieve information of the song lyrics by extracting all duplicate words that are most used in <em>The Queen Is Death </em>album. We will seperate the words into two sentiment categories and added onto the list based on whether its either a negative or a positive word.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1006/1*slcuqTBGjnuOhHLbncmGmw.png" /></figure><p>The most commonly used word across The Smiths albums is “love.” This can be attributed to the shared interests of Morrissey and Marr in poetry, romanticism, and literature. Love songs have timeless appeal, and mentioning love in their tracks certainly resonates with listeners. Thus, I created a wordcloud text visualization that encompasses all of their albums.</p><pre># Read Data<br>allLyrics2 &lt;- read_csv(&quot;The Smiths Lyrics.csv&quot;)<br><br># Filter by album<br>smiths_lyrics &lt;- allLyrics2 %&gt;%<br>  filter(album %in% c(&quot;The Smiths&quot;, &quot;Meat Is Murder&quot;, &quot;The Queen is Dead&quot;, &quot;Strangeways, Here We Come&quot;))<br><br># Tokenize the text data and store it in a tidy format<br>tidy_data &lt;- smiths_lyrics %&gt;%<br>  unnest_tokens(word, line) %&gt;%<br>  anti_join(stop_words) %&gt;%<br>  group_by(album, word) %&gt;%<br>  count() %&gt;%<br>  inner_join(get_sentiments()) %&gt;%<br>  group_by(word) %&gt;%<br>  filter(n_distinct(album) != 4) %&gt;%<br>  group_by(album) %&gt;%<br>  mutate(n = scales::rescale(n),<br>         album = factor(album, levels = c(&quot;The Smiths&quot;, &quot;Meat Is Murder&quot;, &quot;The Queen is Dead&quot;, &quot;Strangeways, Here We Come&quot;))) %&gt;%<br>  arrange(-n)<br><br>ggplot(tidy_data,<br>       aes(<br>         label = word,<br>         size = n,<br>         color = sentiment,<br>         alpha = n<br>       )) +<br>  geom_text_wordcloud_area(area_corr_power = 1) +<br>  scale_size_area(max_size = 11) +<br>  scale_color_manual(values = c(&quot;#f14c38ff&quot;, &quot;#01b0f1ff&quot;)) +<br>  scale_alpha(range = c(.5, 1)) +<br>  theme_minimal() +<br>  facet_wrap(~album, ncol = 2) +<br>  theme(<br>    plot.background = element_rect(fill = &quot;#393536ff&quot;, color = NA),<br>    strip.text = element_text(<br>      family = &quot;bodoni&quot;,<br>      face = &quot;italic&quot;,<br>      size = 20,<br>      color = &quot;white&quot;<br>    ),<br>    plot.margin = unit(rep(1, 4), &quot;cm&quot;),<br>    panel.spacing = unit(.5, &quot;cm&quot;),<br>    plot.title = element_text(<br>      family = &quot;bodoni&quot;,<br>      size = 40,<br>      color = &quot;#B93769&quot;,<br>      hjust = .5,<br>      vjust = .5<br>    ),<br>    plot.subtitle = ggtext::element_markdown(<br>      hjust = .5,<br>      color = &quot;white&quot;,<br>      size = 14<br>    ),<br>    plot.caption = ggtext::element_markdown(<br>      family = &quot;bodoni&quot;,<br>      face = &quot;bold&quot;,<br>      hjust = .5,<br>      vjust = .5,<br>      color = &quot;white&quot;,<br>      size = 10<br>    )<br>  ) +<br>  labs(title = &quot;THE SMITHS&quot;,<br>       subtitle = &quot;(&lt;span style=&#39;color:#01b0f1ff&#39;&gt;Positive&lt;/span&gt; and &lt;span style=&#39;color:#f14c38ff&#39;&gt;Negative&lt;/span&gt;)&lt;br&gt;&lt;br&gt;&quot;,<br>       caption = &quot;&lt;br&gt;Data from &lt;b&gt;{Geniusr}&lt;/b&gt;&lt;br&gt;Visualisation by &lt;b&gt;Andres Gonzalez&lt;/b&gt; (Twitter @AndresAnalytics)&lt;br&gt;Code found at &lt;b&gt;github.com/OKcomputer626&lt;/b&gt;&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ihxDb8IWyd4qm9EP6RX5YQ.png" /><figcaption>The Smiths Wordcloud by Album</figcaption></figure><p>This visualization is a word cloud of the lyrics from The Smiths albums, where the size of each word represents its frequency within the album. The colors of the words indicate their sentiment, with blue representing positive sentiment and red representing negative sentiment. The word cloud is faceted by album, with “The Smiths” appearing first, followed by “Meat Is Murder”, “The Queen is Dead” and “Strangeways, Here We Come.”</p><p>Overall, this word cloud effectively displays the most frequently used words in The Smiths albums and highlights their sentiment, offering an insightful look into the lyrics and themes of the band’s music.</p><p>Among all of The Smiths’ songs, my absolute favorite lines come from the track “There Is A Light That Never Goes Out.”</p><p>Below are a few memorable lyrics from this remarkable band that showcase their talent.</p><blockquote>And if a double-decker bus<br>Crashes in to us<br>To die by your side<br>Is such a heavenly way to die<br>And if a ten ton truck<br>Kills the both of us<br>To die by your side<br>Well the pleasure, the privilege is mine</blockquote><p>This line captures the depth of the narrator’s devotion and love, expressing a sentiment that is both romantic and memorable.</p><p>It’s lovely!</p><p><strong>Conclusion</strong></p><p>Utilizing Spotify’s Web API to retrieve an entire discography along with audio features is an exciting application of Data Science in the realm of music. This allows you to explore not only your favorite bands but also the vast world of music. You can create tailored playlists for your workout routines by combining various metrics and employing machine learning to generate song recommendations based on your taste, or even discover new genres you’ve never heard before. By leveraging statistical techniques and programming with R, it’s possible to analyze interesting trends, such as tracking an artist’s popularity in a time series through their monthly listeners worldwide. Overall, it’s a fulfilling experience to write about and engage with the music you enjoy on Spotify.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=173266b1d697" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>