How does YouTube’s Trending Videos Algorithm Work?

Hayden Poore
Fall 2019 — Information Expositions
6 min readSep 16, 2019

The video sharing platform YouTube is the second most popular social media platform with over 1.9 billion users. Videos shared on the platform are viewed by people all around the world. Having this large of an audience at your disposal is useless unless you know how to properly engage with them. Not every video posted to the site gets millions of views and every hour the site gets over 300 hours of video uploaded.

There are of course videos that are able to reach this massive audience and I wanted to take a look and see if there were any similarities between the videos that did well on the platform. The exact mechanics behind how YouTube’s algorithm for determining trending videos in unknown, the basic explanation is that it is a combination of views, likes, comments, where the video is coming from and age of the video. Using a kaggle data set called Trending YouTube Statistics by a user named Mitchell J (https://www.kaggle.com/datasnaek/youtube-new) I wanted to see if I could in a way reverse engineer their algorithm.

User interaction is definitely a factor in determining if a video is trending or not. I decided to take some averages on the data and found that the average number of views for a trending video is 2360785. This number is not extraordinarily high because there are other factors that contribute to if a video is “trending” worthy. YouTube classifies user interaction as comments likes and dislikes also. After doing some analysis I found that the average number of likes was 74267, dislikes 3711 and comments 8447.

Snapshot from Pandas DataFrame

There was still no clear logic that was made available to me through my first round of analysis so I decided to see if the sentiment score of the title had anything to do with how well the video did and if it ended up trending or not. I used the python library VADER (Valence Aware Dictionary and sEntiment Reasoner) to calculate the sentiment of each video title and see if there was any correlation. VADER determines the sentiment of a phrase and scores it from -1 to 1 from negative to positive respectively.

Bar graph showing the sentiment of the video title vs how many videos shared that same score

Here is the code that I used to generate the sentiment score of each title.

Code for creating a list of sentiment scores for each title in data set

The VADER object is passed in a string of characters and then returns a dictionary of four scores negative, neutral, positive and compound. For the sake of this analysis I only used the compound score as that is an accurate reflection of all the scores.

I was a bit disappointed after my sentiment analysis of the titles because nothing immediately jumped out at me besides the fact having a neutral title (score of 0) was the most popular. Although the data is not super strong if you want to have your video trending its best to go with a more neutral/positive title than anything negative.

I decided that for my next analysis I was going to look at the hour of the day that the video was posted and see if there was an ideal time to post your video.

Number of trending videos by hour

This data set only includes videos from the US so it would make sense that most people are posting their videos in their afternoon. Although posting your video in the afternoon does improve your chance of it trending but does it maximize the potential amount of views it could get? I was curious so I wanted to see what time of day got the most views.

Cumulative Views per Hour

As an aspiring data scientist this graph immediately caught my attention. Why was there such a massive spike of video views at 4 am? Through some analysis I found that some pretty big videos were posted at this time such as Childish Gambino’s This is America with 225211923 views, Ariana Grande’s No Tears Left To Cry’ with 148689896 and Bruno Mars’ — Finesse (Remix) [Feat. Cardi B] [Official Video]’ with 57951412 views. I attribute this to these artists having massive fan bases around the world and in different time zones so unless you’re a music artist with fans from all over the world I would recommend publishing your video in the afternoon.

So we found out that time of day does not necessarily play that huge of a role in determining if a video is considered trending or not, its the user engagement that the video receives. One factor is the percentage of viewers that actually engage with the video in a positive way such as a like or comment.

Calculation of ratio of views to likes

Using the data from the data set I found that on average with a trending video on YouTube 3% of viewers will leave a like. This is the type of direct user engagement that the algorithm looks like and if you want your video to become trending is crucial to meet or exceed that figure.

Another interesting statistic that I found was the engagements that came through comments. Although people are less likely to leave comments it still plays a crucial role in calculating user engagement.

The average percentage of people leaving a comment on a trending YouTube video is a measly 0.004 percent. This may seem low at first but then you have to realize the volumes of views that most of these videos are getting and puts the overall average of comments per video at 8447.

Conclusion

Cracking the exact code to the YouTube trending videos algorithm is a little beyond my current expertise but through this data analysis I found some helpful things that could improve the your chances of getting your video featured on the trending section of YouTube. The first thing is the title and that is to keep is relatively neutral titles that were extremely positive or negative had a lower chance of becoming trending than those who were more neutral. The second thing is the time of day that you post your video. Unless you are a major celebrity will fans all over the world it is best to post during the afternoon time in order to maximize engagement. When I say the term maximizing engagement I really mean improving three three things. Views, likes and comments. If you want your video to become trending encourage your audience to like and comment on your video and try and aim to get 3% of viewers to like and 0.004% to comment and your chances vastly improve.

--

--

Hayden Poore
Fall 2019 — Information Expositions

Information and Data Science Student with a minor in Business Analytics at the University of Colorado Boulder. Currently seeking a Summer 19 Internship.