<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/voyage-to-the-intelligent-music-streaming-service-ep-1-the-analysis-of-top-ranked-songs-and-artists/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://nycdatascience.com/blog/student-works/voyage-to-the-intelligent-music-streaming-service-ed1/"> R – NYC Data Science Academy Blog</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p><img sizes="(max-width: 1024px) 100vw, 1024px" src="https://i2.wp.com/nycdatascience.com/blog/wp-content/uploads/2018/03/smartphone-technology-music-headphones-1024x683.jpg?w=450&ssl=1" alt="" class="wp-post-image" data-recalc-dims="1"></p>
<h2>Prologue</h2>
<p>In 2013, I had worked on developing a Music Recommendation System as a pilot project, which had not even completed. There were lots of reasons, but the critical one was the choice and concentration strategy of my division. Since then, I keep these passion in my deep mind for a long time, but could not throwing it away. Now I feel like to reboot this unfinished, out-dated project from the scratch by myself. This journey will cover not only for the music recommendation system but also all the smart artificial intelligence system. Even though I am not aware of where the end of this travel, enjoying it would enough.</p>
<p>My journey start with an analysis of the current music streaming trend by using <a rel="nofollow" href="https://spotifycharts.com/regional" target="_blank">database from Spotify.</a></p>
<h3><em><strong>Why Spotify ?</strong></em></h3>
<p>The Spotify is a music streaming service founded in 2006 in Sweden, which provides convenient user interface to listen to music and share playlists with other users in two ways: one is free of charge with advertisements, the other is to purchase a subscription for unlimited ad-free music streaming. According to the recent statistic provided by <em>Statista</em> gives information on the number of paying subscribers to Spotify’s music streaming service. As of January 2018, Spotify had 70 million paying subscribers worldwide, up from 60 million paying subscribers in July 2017. This rapid and steady growth of paid subscribers give a good reason to investigate current trend of music for many data scientists.</p>
<div><a rel="nofollow" href="https://plot.ly/~canslove/1" target="_blank"><img src="https://i1.wp.com/plot.ly/~canslove/1.png?w=456&ssl=1" data-recalc-dims="1"></a></div>
<h3><em><strong>Data Source</strong></em></h3>
<p>Spotify data set in Kaggle has been used for the analysis.</p>
<ol>
<li><a rel="nofollow" href="https://www.kaggle.com/edumucelli/spotifys-worldwide-daily-song-ranking" target="_blank">spotifys-worldwide-daily-song-ranking</a> (for this analysis)</li>
<li><a rel="nofollow" href="https://www.kaggle.com/nadintamer/top-tracks-of-2017" target="_blank">top-tracks-of-2017</a> (for additional information)</li>
<li><a rel="nofollow" href="https://www.kaggle.com/artimous/every-song-you-have-heard-almost/data" target="_blank">every-song-you-have-heard-almost</a> (for lyric analytics)</li>
<li><a rel="nofollow" href="https://www.kaggle.com/max-mind/world-cities-database/data" target="_blank">world-cities-database</a> (for city mapping)</li>
</ol>
<p>The first data set has mainly used here. This contains the daily ranking of the 200 most listened songs in 53 countries from 2017 and 2018 by Spotify users. It contains more than 2 million rows, which comprises 6629 artists, 18598 songs for a total count of one hundred five billion streams count. Each row contains a ranking position on a specific day for a song. For instance, the first 200 rows present the ranking for the 1st of January in Argentina. The following 200 rows will contain the ranking for the 2nd of January in Argentina. The regions are alphabetically sorted. To build an interactive shiny app efficiently, every 100 ranking songs and artists in each country are filtered out. The reduced data set is as below:</p>
<table>
<tbody>
<tr>
<td><span>RANKING </span></td>
<td><span>TRACK_NAME </span></td>
<td><span>ARTIST </span></td>
<td><span>STREAMS </span></td>
<td><span>DATE </span></td>
<td><span>REGION </span></td>
</tr>
<tr>
<td><span>Min. : 1.00</span></td>
<td><span>Length:1874422</span></td>
<td><span>Length:1874422</span></td>
<td><span>Min. : 1001 </span></td>
<td><span>Length:1874422</span></td>
<td><span>Length:1874422 </span></td>
</tr>
<tr>
<td><span>1st Qu.: 24.00</span></td>
<td><span>Class :character</span></td>
<td><span>Class :character</span></td>
<td><span>1st Qu.: 4004</span></td>
<td><span> Class :character </span></td>
<td><span> Class :character</span></td>
</tr>
<tr>
<td><span>Median : 49.00</span></td>
<td><span>Mode :character</span></td>
<td><span>Mode :character</span></td>
<td><span>Median : 12341</span></td>
<td><span>Mode :character</span></td>
<td><span>Mode :character</span></td>
</tr>
<tr>
<td><span>Mean : 49.25</span></td>
<td></td>
<td></td>
<td><span>Mean : 70325 </span></td>
<td></td>
<td></td>
</tr>
<tr>
<td><span>3rd Qu.: 74.00</span></td>
<td></td>
<td></td>
<td><span>3rd Qu.: 44110</span></td>
<td></td>
<td></td>
</tr>
<tr>
<td><span>Max. :100.00</span></td>
<td></td>
<td></td>
<td><span>Max. :11381520</span></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
<h3><em><strong>Motivation</strong></em></h3>
<p>The trend analysis will give us to explore how artists and songs’ popularity varies in time. By using the daily ranking of the 100 most listened songs in 53 countries listened by Spotify users,<br>
– track the current trend of music and forecast the next trend;<br>
– track the flow or influence of top ranked musics from one country to another, then make some insight of business model for commercial service such as localized advertisement;<br>
– make a distribution/influence map by region, country, genre(music categories), and other information (such as season, weather, social event, etc);<br>
– check a possibility to develop a music recommendation service based on user-preference.</p>
<h3><em><strong>Insights</strong></em></h3>
<p><em>Predict</em><br>
– what type of songs will be popular in the future?<br>
<em>Forecast</em><br>
– what is the next trend of music in this country?<br>
<em>Share</em><br>
– how are popular songs propagate country by country?<br>
<em>Pattern</em><br>
– can we categorize countries by their music trend?<br>
<em>Dominant factors</em><br>
– something <i>common </i>in lyrics, ranks, or artists ?<br>
<em>Business Models</em><br>
– what kind of features make a tendency or trend in this field?<br>
<em>Influence Map</em><br>
– how long does a top ranked songs take to get into the ranking of neighbor countries?<br>
<em>Recommendation </em><i>Service</i><br>
– is this possible? Any pattern? Any user-preference country by country?</p>
<p>All of these queries will be touched one by one during this journey, and <a rel="nofollow" href="https://canslove.shinyapps.io/spotify_music/" target="_blank">the visualization app</a> built in this episode would be the first set foot for an intuitive grasp.</p>
<h3><em><strong>Data Analysis</strong></em></h3>
<p>There are 53 countries categorized to ‘region’ in this data set. Nine of them are in Asia, 26 in Europe, 16 in South America, and 2 is Canada and the United States. Currently no countries form Africa and Middle East are included. The distribution is as shown in the below map. This data set has been provided by Spotify, and it is probable that when the countries have more influential local music streaming service provider, the subscriber of the Spotify could be too small to be counted on the data statistics. For example, there are three major music streaming service companies in South Korea, and their market-share is more than 90% in total.</p>
<div><a rel="nofollow" href="https://plot.ly/~canslove/23" target="_blank"><img src="https://i2.wp.com/plot.ly/~canslove/23.png?w=456&ssl=1" data-recalc-dims="1"></a></div>
<p>Total aggregating result of the number of all ‘streams’ by countries shows that <em>a streaming power</em> – the number of streams downloaded a year – is concentrated on some of countries such as the US, Great Britain, Brazil, Mexico, etc. When we see the top 10 countries – ‘The USA’, ‘Great Britain’, ‘Brazil’, ‘Mexico’, ‘Germany’, ‘Ecuador’, ‘Netherlands’, ‘Sweden’, ‘Australia’, ‘Philippines’ – not all the countries speaks English as a first language. So <em>the streaming power</em> has nothing to do with a language, however we can think that the Spotify is a powerful streaming-service provider in these countries. This makes sense why Sweden is in top 10. For an in-depth analysis on the trend and tendency, the first top 7 to 10 countries will be in initial research stage.</p>
<div><a rel="nofollow" href="https://plot.ly/~canslove/25" target="_blank"><img src="https://i2.wp.com/plot.ly/~canslove/25.png?w=456&ssl=1" data-recalc-dims="1"></a></div>
<p>In a wide common sense, there is strong correlation between top songs and top artists, so the “<em>Shape of You</em>” and <em>Ed Sheeran</em> does. They were both very popular on Spotify in global 2017 based on the below table which is calculated by maximum downloaded stream.</p>
<p><img src="https://i0.wp.com/nycdatascience.com/blog/wp-content/uploads/2018/03/020.top7ctry.png?w=450" data-recalc-dims="1"><br>
* global, us, gb(GreatBritain), mx(Mexico), br(Brazil), de(Germany), es(Ecuador), se(Sweden)</p>
<p>When we aggregate the number of download-streams for the ‘Shape of You’ in each country, the top rank of countries described in below pie chart is almost same for the calculated streaming power list. Only a small amount of order difference there is.</p>
<div><a rel="nofollow" href="https://plot.ly/~canslove/9" target="_blank"><img src="https://i0.wp.com/plot.ly/~canslove/9.png?w=456&ssl=1" data-recalc-dims="1"></a></div>
<p>To find out some patterns in the time series,  the number of streams are measured in monthly basis over top seven ranked countries for streaming power. There are not big significance but we can see that the number of streams in January and February are significantly lower than other month. Why? Does people do other things than listening to musci in the beginning of new year ? Or not many new music has been released in those duration? With only this data set, it is difficult to say there is a tendency in the beginning of the year. This could had happened only in 2017. For a clarification, further data set – at least for 2015, 2016.</p>
<div><a rel="nofollow" href="https://plot.ly/~canslove/13" target="_blank"><img src="https://i0.wp.com/plot.ly/~canslove/13.png?w=456&ssl=1" data-recalc-dims="1"></a></div>
<p>To trace the popular music trend, periodic popular songs are calculated and top 3 songs for each country are listed as shown in below three figures. Date for first one is whole 2017 year, second is from Jan.2017 to Jul.2017, and the last is from Aug.2017 to Dec.2018. It can be seen that some songs were loved in global, but some are only for specific country. When the song or artist are really loved in specific country, it will be most likely the homeland of the artist. For example on the ‘shape of you’ by Ed Sheeran, even though it is a great hit across all over the world, the number of streams in Great Britain are almost twice than other country, and Sheeran was born in Halifax, West Yorkshire. And the next is linguistic factors. It make sense that the ‘shape of you’ has been so popular in the US. Language reflects a culture and music cannot be fully understandable without the cultural consensus.</p>
<div><a rel="nofollow" href="https://plot.ly/~canslove/15" target="_blank"><img src="https://i0.wp.com/plot.ly/~canslove/15.png?w=456&ssl=1" data-recalc-dims="1"></a></div>
<div><a rel="nofollow" href="https://plot.ly/~canslove/19" target="_blank"><img src="https://i1.wp.com/plot.ly/~canslove/19.png?w=456&ssl=1" data-recalc-dims="1"></a></div>
<div><a rel="nofollow" href="https://plot.ly/~canslove/21" target="_blank"><img src="https://i1.wp.com/plot.ly/~canslove/21.png?w=456&ssl=1" data-recalc-dims="1"></a></div>
<p>As you can see, the data set looks simple but getting insight form this data requires lots of trial by changing date, artist, steams, and selecting various countries, which has regarded as redundant time consuming. For this reason, interactive visualization tool are designed to analyze this. In fact, all the above findings had been from the visualization tool as introduced in the next chapter.</p>
<h3><em><strong>Data Visualization Tool</strong></em></h3>
<p><a rel="nofollow" href="https://canslove.shinyapps.io/spotify_music/" target="_blank">This app</a> is specially designed not only to visualize for better understanding but also to analyze and find insight form the Spotify data set.</p>
<h4>ShinyApp</h4>
<p><a rel="nofollow" href="https://canslove.shinyapps.io/spotify_music/" target="_blank">Spotify_Music_Analyzer</a></p>
<h4>Data Table</h4>
<p>Number selector is provided for any numerical columns such as Ranking, Streams, and DATE for sorting whereas string-based filter function is provided for the categorical columns such as Track_name, Artist, and Region.</p>
<p><img src="https://i2.wp.com/nycdatascience.com/blog/wp-content/uploads/2018/03/data_table.png?w=450" data-recalc-dims="1"></p>
<h4> Chart</h4>
<p>Four types of graph can be plotted with facet_wrap by selecting countries. Start and End date can be selected from 2017-01-01 to 2018-01-31. Whenever the Artist and related Track_name is chosen, corresponding plot will be drawn immediately. When you don’t select Region, countries – the USA, Great Britain, France, Ecuador) operate over the simulation by default.</p>
<p><img src="https://i2.wp.com/nycdatascience.com/blog/wp-content/uploads/2018/03/020.histogram.png?w=450" data-recalc-dims="1"></p>
<h4>Graph</h4>
<p>This section show two graph with corresponding selections. One is a trend curve for the Artist, another is a trend curve for the Track over selected countries. This graph really helps to understand how long the song sustain in top rank and when a new trend come up.</p>
<h3><img src="https://i0.wp.com/nycdatascience.com/blog/wp-content/uploads/2018/03/030.plot_.png?w=450" data-recalc-dims="1"></h3>
<h4> Status</h4>
<p>Selecting cutoff rankings, the amount of streams of songs in the ranking calculated and compared with others over respective countries. This can give a insight for an analysis of a music streaming similarity presenting precise number of downloaded streams.</p>
<p><img src="https://i0.wp.com/nycdatascience.com/blog/wp-content/uploads/2018/03/040.barchart.png?w=450" data-recalc-dims="1"></p>
<h4>Word Cloud</h4>
<p>Originally this is intended to forecast next trend of music genre by analyzing the statistics of lyrics used in popular music. Currently, this word cloud shows a characteristic of trendy name of songs and popularity of a artist. When the lyric data set has been cleaned and transformed, the forecasting service will be provided. You can find that ‘Drake’, ‘Chainsmokers’, and ‘Sheeran’ were the most popular artists in the USA from January to March in 2017.</p>
<p><img src="https://i2.wp.com/nycdatascience.com/blog/wp-content/uploads/2018/03/050.wordcloud.png?w=450" data-recalc-dims="1"></p>
<p><img src="https://i1.wp.com/nycdatascience.com/blog/wp-content/uploads/2018/03/060.wordcloud.png?w=450" data-recalc-dims="1"></p>
<h3><em><strong>Takeaway</strong></em></h3>
<p>Through this app, several insights has came up with results.</p>
<ul>
<li>Whatever the reason may be, The Spotify has not many subscribers in Middle East, Africa, China, and South Korea.</li>
<li><em>A streaming power</em> – the number of streams downloaded a year – is concentrated on some of countries, but not only English-speaking countries.</li>
<li>‘Shape of You’ is the most downloaded, and streamed song by Spotify users all over the world in 2017, and so Ed Sheeran is the artist.</li>
<li>Spotify users had not used streaming service as much as usual in January and February in 2017.</li>
<li>Music reflects culture, so it is highly correlate with its language.</li>
<li>‘Drake’, ‘Chainsmokers’, and ‘Sheeran’ were the most popular artists in the USA in 2017.</li>
<li>Popular music had been spread out across borders without much delay. Why?  Ecosystem of On-line streaming ?</li>
</ul>
<h3><em><strong>Next Place for Visit</strong></em></h3>
<p>The start point is important. There are several steps for data science, and the very first and the most important part is data selection and its reliability. The next episode deals with the journey to find a reason why the Spotify dataset is one representative sample for music streaming trend analysis.</p>
<h2>Epilogue</h2>
<p>“<a rel="nofollow" href="https://youtu.be/__VQX2Xn7tI" target="_blank">We’ve only just begun this journey</a>” by Carpenters.</p>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://nycdatascience.com/blog/student-works/voyage-to-the-intelligent-music-streaming-service-ed1/"> R – NYC Data Science Academy Blog</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/LGseH1vZfiM" height="1"></a></div>