<?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 Brendon Ho on Medium]]></title>
        <description><![CDATA[Stories by Brendon Ho on Medium]]></description>
        <link>https://medium.com/@brendon.ho01?source=rss-2943daaf7229------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*rU6-nuWVyaJ01GZb.</url>
            <title>Stories by Brendon Ho on Medium</title>
            <link>https://medium.com/@brendon.ho01?source=rss-2943daaf7229------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 23:04:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@brendon.ho01/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[Predicting Popular Spotify Songs]]></title>
            <link>https://medium.com/@brendon.ho01/predicting-popular-spotify-songs-1dc1ff5fea70?source=rss-2943daaf7229------2</link>
            <guid isPermaLink="false">https://medium.com/p/1dc1ff5fea70</guid>
            <category><![CDATA[spotify]]></category>
            <category><![CDATA[projects]]></category>
            <category><![CDATA[regression]]></category>
            <category><![CDATA[predictions]]></category>
            <category><![CDATA[r]]></category>
            <dc:creator><![CDATA[Brendon Ho]]></dc:creator>
            <pubDate>Wed, 06 May 2020 15:30:14 GMT</pubDate>
            <atom:updated>2020-05-06T15:30:14.806Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/980/1*gDNJvhnnYmt15VwiGRC97A.jpeg" /><figcaption>Spotify Music Logo</figcaption></figure><h3>Abstract</h3><p>Music is such an important aspect in our lives. For most people, it is part of their daily routine. However, this outbreak has increased our music listening activities. Therefore, it is interesting as a music producer myself to see what the charts would look like this year especially during the outbreak. Unfortunately, there isn’t sufficient data for 2020 music since the year is still going on. Therefore, this project aims to attempt to predict the top 10 songs for 2019 and compare the actual results of that year. The research will be conducted in 3 parts: visualizing the data, testing the hypothesis on our data, and creating a regression model for the data we use.</p><h4>Choosing a Data set</h4><p>For this project, I decided to use a data set that took the top 50 songs of the year ranging from 2010 to 2019 with 2019&#39;s data cut off so that we can use that as the test set. The data set has the song title, as well as the bpm, energy level, popularity, acoustic level, and more. The link is right here:</p><p><a href="https://www.kaggle.com/leonardopena/top-spotify-songs-from-20102019-by-year">Top Spotify songs from 2010-2019 - BY YEAR</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uK2XK48qJbhEdsG5TyA40A.png" /><figcaption>A portion of 2010’s data</figcaption></figure><h3>Visualizing and Modeling Data Accurately</h3><p>Before we go on to creating a regression model, we need to visualize our data to come to an understanding on which data variables are significant into factoring our model. For that, we need to choose a good data visualization and a good plot.</p><h4>Choosing a Visualization Method</h4><p>Choosing a method to accurately portray our data is crucial to moving on. It is imperative that we don’t choose a plot that misleads us to incorrect assumptions and hypotheses.</p><p>Lets start with the two most well-known plots: The bar graph and plotting points. We will use the song bpm as our y-axis and the year of the song as our x-axis.</p><p>The bar graph looks like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ec4f71d03fc236257494dee09fc73b26/href">https://medium.com/media/ec4f71d03fc236257494dee09fc73b26/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fawqlwt2lq6l-i3988WC3A.png" /><figcaption>BPM by year using bar graph: a poor visualization</figcaption></figure><p>As you can see, bar plots are an extremely poor visualization in this scenario. It tells us nothing about the change in bpm per year; just collapsing a bunch of bpms per year with no direction.</p><p>Let’s look at the dot plot:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/011f46ea432f409005e92116f9b2cfb1/href">https://medium.com/media/011f46ea432f409005e92116f9b2cfb1/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KSxIV3sxCmNnzu40CDE-Eg.png" /><figcaption>BPM by year using bar graph: looks a little better but still lacks clarity</figcaption></figure><p>A dot plot looks a little better than the bar plot as we can slightly see the concentration of the bpms per year. However, it is still difficult to tell where most of the bpms lie each year and therefore lacks a clear direction. There is something better we can use.</p><p>When we try using a box &amp; whisker plot it looks like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8ecb9166f262b11fb84b99a68b7422db/href">https://medium.com/media/8ecb9166f262b11fb84b99a68b7422db/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A9F5BBBsXHpwJVuoV7Up9w.png" /><figcaption>BPM by year using box and whiskers: much better</figcaption></figure><p>This looks more like it. The thick black line clustered all the dots into one average per year. That way, we can see a clear direction of generally where the bpm is going per year. It seems that it starts to go lower as the years go but we will get there later on.</p><h4>Choosing a Variable to Visualize</h4><p>Now that we have a good way to visualize our data, now we need to find one or more variables that would help to find a trend in our data in order to formulate our hypothesis and create our model. For that, we take advantage of the mean in each of the years and see the trend that way. For this I used trial and error, testing out each variable and seeing which had the most noticeable trend.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6DU0LrlJj4DNRCBNXI7hTw.png" /><figcaption>Song energy per year shows a slight downward trend</figcaption></figure><p>What I found was that the song energy was the most noticeable trend. It has a slight downward trend per year which was quite interesting. We can induce from this data and hypothesize that song energy level decrease as years go by. However, with this kind of slighter trend we need to test it. Therefore, we will put our data under hypothesis testing.</p><h3>Hypothesis Testing</h3><p>We want to test our hypothesis is valid before we move on to creating our model. Otherwise, our model would be inaccurate, pointless, and based off chance. Simply comparing the mean of the values doesn’t tell us much, and we need to find the p-values to measure significance.</p><p>For this, we will use multiple hypothesis testing. Specifically, we will conduct multiple permutation tests to obtain multiple p-values. Note, since our hypothesis is that each year brings a decrease in energy, our NULL hypothesis must be that there is not significant change in energy between the years.</p><p>Choosing the type of p-value testing was important too. Between a single sample and two samples hypothesis test, it was clear which one we had to choose. Since we have statistics from two years that we were choosing from, it was obvious that we chose a two samples hypothesis test. In addition, there is the matter of a one-tail and two-tail test. Since we were looking for a direction of an effect — namely the direction of song energy — in one side instead of a relationship in both direction, it made more sense to choose a one-tailed test.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cab342cd0910495e34a1398a9fc25a5f/href">https://medium.com/media/cab342cd0910495e34a1398a9fc25a5f/href</a></iframe><p>When conducting the hypothesis tests, it turns out that energy difference is relatively significant when comparing energy year by year. That data seemed to reject the null hypothesis more often than other factors as I tested each variables. Of course there were a few ups and downs, however, out of the rest of the data, it was the most significant and showed most promise.</p><p>It is a good thing that we checked our hypothesis. Otherwise, we would have been getting weird data that wouldn’t matter. Now, we can go on creating out regression model.</p><h3>Creating The Regression Model</h3><p>Now it is time to create our Regression model. Revisiting our graph, it seems to make sense that we use a linear regression model to model our data. Since we are predicting for one year, we get one value and pick 2019 values that are closest to that predicted value.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ecf69590073e350e57bcc3113470cfe9/href">https://medium.com/media/ecf69590073e350e57bcc3113470cfe9/href</a></iframe><p>What we see is a RMSE error value of 17.12, which in all honesty is not too bad in this situation. There were a lot of high and low energy levels. Therefore, considering that, it was a good result. I also tried other regression models: exponential, log-log, quadratic; the error on these models were just too large or larger than linear regression; it made no sense to use these models.</p><h4>Results</h4><p>What we got was a predicted mean energy level of ~64. What we do from here is pick any songs that are closest to the 64 energy level. Using a while loop, I printed out all of the results with the following code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cf612c3ba070a2341830408d085f9edb/href">https://medium.com/media/cf612c3ba070a2341830408d085f9edb/href</a></iframe><p>Since it only grabbed the first appearances of the closest, the order does not matter in this case. The results are here:</p><ol><li>Beautiful People (feat. Khalid)</li><li>Find U Again (feat. Camila Cabello)</li><li>South of the Border (feat. Camila Cabello &amp; Cardi B)</li><li>Truth Hurts</li><li>How Do You Sleep?</li><li>Higher Love</li><li>I Don’t Care (with Justin Bieber)</li><li>Call You Mine</li><li>Sucker</li><li>Señorita</li></ol><p>In general, the results were not too shabby. Out of the 10 predicted, it was able to grab 4 accurate predictions from the actual top 10 list (Señorita, How Do You Sleep, South of the Border, Truth Hurts). In addition, the other 6 predictions all lie around the top 20 range of the entire 2019 data set. Considering that this was a basic model that used linear regression and one variable to determine it, the results were pretty nice.</p><h3>Wrapping Up</h3><p>Ultimately, this was a fun project to work on. It was interesting to see and understand working patterns in our music and how our tastes change gradually as years go by. In addition, it’ll be interesting to see how 2020’s data will be affected since these times of distress might introduce an anomaly in our data.</p><p>This data showcases how we approached music back then, how we approach it now and how we will do so in the future. There were a bunch of other trends that I noticed regarding the types of music we like and it was quite astonishing.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1dc1ff5fea70" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>