Author(s),: Daksh Trehan, Machine Learning. How to make the most out of YouTube’s API. Via Kostadin I last week wrote about YouTube Algorithm and its AI workflow. Based on information about its recommendation system I believe there are flaws. It prefers long videos to have high viewing time. Also, it recommends longer duration videos once a period has passed. YouTube is full of low quality content, clickbait videos and poor-quality content. However it’s recommended. No actions will be taken if false information was given. DislikeCount and LikeCount are not able to influence the quality of recommendations. Chris Lovejoy wrote a fascinating article about the YT algorithm that showed how he created a personal recommendation system using the YT API. Inspiring by Chris Lovejoy’s thought process, and his insightful article, I created my own YT recommendation system using the YT APIs. Following a personal plan, the plan was to build a system which can recommend relevant videos. It was not about finding the most relevant video from a large number of 1000s, but to find one that statistically matches my preferences. This plan will save me time searching for the right content, and may help me avoid being distracted. Unsplash photo by Nubelson Fernandes. The workflow involved getting the video information from YouTube and ranking them according to my preferences. To make things easier, we will be able to automate this process with Python later. YouTube API: This is how you get familiar with the project. You will get all information regarding the video you need, whether it is descriptive or statistical. It can be used for both channels and videos, as it returns metadata. An API key is required to start the API. This could be created using Developer Console. To get the content you need based on your query, follow this code. We will get a JSON object as the output. This can later be parsed to extract useful information. These would give us descriptive attributes about a channel/video. We need statistical attributes. To do this, take the id of descriptive attributes and use the code below. How to Create the Perfect Formula YouTube’s recommendation system is not my favorite. It lacks some important features, or perhaps I just have a different taste. After I was familiar with YouTube API, and was able to generate relevant information, it was now time for me to turn on my creative machine. A good video could be based on many factors. You could consider the number of views, length, satisfaction rate, and the content’s relevance to your search query. It would be easiest to settle for a video that has a large view count. However, it is not difficult to see a video that gets 100k views if the channel has 10M subscribers. If 10k subscribers view 100k content, it is clear that the content was of high quality. To choose the most relevant videos, a ratio of view to subscriber might be the most useful metric. The ratio can be increased if the subscribers are low. The code was slightly modified and I added limits. Videos should have a minimum 10k view count and 1k subscribers. View count and subscribers are not the only measures of rank. I introduced likecount-to-dislikecount ratio to further pick relevant and trustworthy content. Adding the view-to-subscriber ratio and likecount-to-dislikecount ratio, I developed a score for each video. YouTube content is assumed to be at its best within 24-48 hours, fetch the most views, and have the highest satisfaction rate. However, this is not the case. I chose to make each query manual. For a more precise result I tweaked the descriptive attributes to see if there was a query in the description and the title. The number of queries that were present in both the title and the description was counted. I followed the “More the Merrier” idea. At the end, I changed my final score function. Focus on keywords in the title and description. Then, you should return content that contains maximum content. Later return content with maximum view-to-subscriber ratio and likecount-to-dislikecount ratio. The YouTube algorithm workflow was designed by Dakshtrehan. All Rights Reserved. I ran the query “Kubernetes” through my workflow and received this result. Although the results are reliable and great, I think there could be more. It was an enjoyable project that focused on understanding YouTube’s API as well as YouTube’s recommendation systems workflow. You can conclude the workflow by entering the following code: Enter the query, the timeframe, and the API key in order to extract the videos. Descriptive or statistical attributes can be used to filter videos. Sort the videos. The output can be displayed. The full source code can be found at my Github. Closing thoughts The project is still at its infancy and needs to be refined. Some steps you can consider are: Automating the entire process of retrieving customized videos. To get better results, a better metric implementation is needed. The code can be deployed on public cloud servers. Subscribe to Daksh Trehan’s Weekly Newsletter if you enjoyed this article. This article should have given you a glimpse into YouTube’s recommendation system, and shown how to create one. However, this article only focuses on generic YouTube recommendation system concepts. It is not based upon any theories or information that users have shared with YouTube developers. We can get even more results by pushing the personalized algorithm further. Refer to:  YouTube uses AI to suggest videos.  Exploring YouTube Data API: Indian Pythonista  YouTube Data API Find me on Web: www.dakshtrehan.com Follow me at LinkedIn: www.linkedin.com/in/dakshtrehan Read my Tech blogs: www.dakshtrehan.medium.com Connect with me at Instagram: www.instagram.com/_daksh_trehan_ Want to learn more? YouTube uses AI to suggest videos. Let’s toast how I personalized my YouTube recommendation with the YT API This story was first published on Medium by . People are responding and highlighting it on Medium. Published via
We monitors and writes about new technologies in areas such as technology, innovation, digitization, space, Earth, IT and AI.