Name: Towards AI Legal Name: Towards AI, Inc. Description: Towards AI is the world's leading artificial intelligence (AI) and technology publication. Read by thought-leaders and decision-makers around the world. Phone Number: +1-650-246-9381 Email: [email protected]
228 Park Avenue South New York, NY 10003 United States
Website: Publisher: https://towardsai.net/#publisher Diversity Policy: https://towardsai.net/about Ethics Policy: https://towardsai.net/about Masthead: https://towardsai.net/about
Name: Towards AI Legal Name: Towards AI, Inc. Description: Towards AI is the world's leading artificial intelligence (AI) and technology publication. Founders: Roberto Iriondo, , Job Title: Co-founder and Advisor Works for: Towards AI, Inc. Follow Roberto: X, LinkedIn, GitHub, Google Scholar, Towards AI Profile, Medium, ML@CMU, FreeCodeCamp, Crunchbase, Bloomberg, Roberto Iriondo, Generative AI Lab, Generative AI Lab Denis Piffaretti, Job Title: Co-founder Works for: Towards AI, Inc. Louie Peters, Job Title: Co-founder Works for: Towards AI, Inc. Louis-François Bouchard, Job Title: Co-founder Works for: Towards AI, Inc. Cover:
Towards AI Cover
Logo:
Towards AI Logo
Areas Served: Worldwide Alternate Name: Towards AI, Inc. Alternate Name: Towards AI Co. Alternate Name: towards ai Alternate Name: towardsai Alternate Name: towards.ai Alternate Name: tai Alternate Name: toward ai Alternate Name: toward.ai Alternate Name: Towards AI, Inc. Alternate Name: towardsai.net Alternate Name: pub.towardsai.net
5 stars – based on 497 reviews

Frequently Used, Contextual References

TODO: Remember to copy unique IDs whenever it needs used. i.e., URL: 304b2e42315e

Resources

Take our 85+ lesson From Beginner to Advanced LLM Developer Certification: From choosing a project to deploying a working product this is the most comprehensive and practical LLM course out there!

Publication

How I personalized my YouTube recommendation using YT API?
Latest

How I personalized my YouTube recommendation using YT API?

Last Updated on June 7, 2021 by Editorial Team

Author(s): Daksh Trehan

Machine Learning

How to utilize most of YouTube’s API?

Via Kostadin

Last week, I wrote about how YouTube Algorithm works and the AI workflow behind it. But based on the information available regarding its recommendation system, I think there are some flaws inΒ it:

  • It highly prefers watch time and obviously, longer videos will have high watch time and it tends to recommend higher duration videos after a certainΒ period.
  • YouTube has a lot of clickbait videos, low-quality content and yet it is recommended and no actions are taken on false information imparted.
  • Satisfaction rates such as LikeCount, DislikeCount have little effect on recommendations that could be improved.

During my research regarding the YT algorithm, I found a really interesting article by Chris Lovejoy where using YT API, he managed to create a personalized recommendation system. Inspired by his thought process and an insightful article, I decided to create my own YT recommendation algorithm using YTΒ APIs.

The Plan

The plan was to create a system that can suggest relevant videos following a personalized plan. The motive was to avoid looking for the best video in a pool of 1000s of videos but rather to get a video that statistically suits myΒ taste.

The plan could save me a lot of hours looking for that particular relevant content and maybe help me to avoid distraction.

Photo by Nubelson Fernandes onΒ Unsplash

The workflow consisted of using getting video information using YouTube’s API and then rank them statistically according to my taste. Later, to have some ease we can also automate the whole process usingΒ Python.

Getting familiar with YouTube’s API

YouTube API is the car driving this project. It will bring you every sort of information about the video, be it, statistical or descriptive.

Referring to the documentation, it can work both for channels as well as videos and return us with their respective metadata.

To start with the API, we need an API key that could be generated using Developer Console.

Follow the below code to get content based on yourΒ queries.

The output will leave us with a JSON object, which could be later parsed and useful information can be extracted.

This would provide descriptive attributes of a video/channel.

To get statistical attributes, we need to take id from descriptive attributes and follow the following code.

Creating the PerfectΒ Formula?

I’m not a big fan of YouTube’s recommendation system. I think it lacks several important attributes or maybe I have got a peculiarΒ taste.

Now that I’d got familiar with YouTube API and can easily generate useful information, it was time to switch on my creative machine and develop ranking metrics that could suit my preferences.

Several factors could make a good video. It could be the view count, watch duration, the satisfaction rate of video(like comment, share), or maybe more relatable tags to my searchΒ query.

The easiest approach would be to settle with a video with a high view count, but logically, if a channel has 10M subscribers then getting 100k views on a video won’t be a big deal for him. But if some content of a channel with 10k subscribers hit 100k view count, we can infer the content was up to theΒ mark.

In that case, getting a view-to-subscriber ratio might be the best metric to choose relevantΒ videos.

But, the content of the channel with a low subscriber count can boost the ratio. I tweaked the code a little bit and added some limits and set the videos to have at least 10k views and 1k subscribers.

Further, view count and the number of subscribers couldn’t be the only measure of ranking. 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.

It is universally assumed that any content on YouTube is at its prime time within 24–48 hours and fetch most views and satisfaction rate. But, contrary to the fact, I decided to keep it manual for eachΒ query.

To get a precise result, I also tweaked around with descriptive attributes and checked if the β€œquery” is present in both the title as well as description.

I counted the occurrence of queries in the title as well as the description. And followed the idea of β€œMore the Merrier”.

And at the last step, I modified my final score function. First, focus on keyword in title and description, return with content with maximum content. Later return content with maximum view-to-subscriber ratio and likecount-to-dislikecount ratio.

YouTube algorithm workflow, Designed by Daksh Trehan, All RightsΒ Reserved

Final Result

I tested my workflow for query β€œKubernetes” and got following result.

The results fetched are great and reliable but in my opinion, things could get a littleΒ better.

Overall, it was a fun project revolving around the understanding of YouTube’s API and YouTube’s recommendation system workflow.

The workflow of the code can be concluded as:

  • Manually enter the query, time frame, and API key to extractΒ videos.
  • Filter videos according to Descriptive and Statistical attributes.
  • Rank theΒ videos.
  • Display theΒ output.

You can find the full code at myΒ Github.

Closing Thoughts

The project is still in its initial stages and could be improved a lot, some of the steps that can be taken into accountΒ are:

  • The whole process of fetching personalized videos could be automated.
  • A better metric implementation to get even betterΒ results.
  • Deployment of the code on cloud servers for publicΒ use.

If you like this article, please consider subscribing to my newsletter: Daksh Trehan’s Weekly Newsletter.

Conclusion

Hopefully, this article has given you an insight into the YouTube recommendation system and how one can construct one forΒ them.

But, the information portrayed in this article regarding generic YouTube recommendation systems is solely based on some theories that are experienced by users or publicized by YouTube developers. The personalized algorithm could be pushed further to its limits and we can fetch even betterΒ results.

References:

[1] I created my own YouTube algorithm (to stop me wastingΒ time)

[2] How is YouTube using AI to recommend videos?

[3] Exploring YouTube Data API: Indian Pythonista

[4] 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?

How is YouTube using AI to recommend videos?
Detecting COVID-19 Using Deep Learning
The Inescapable AI Algorithm: TikTok
GPT-3 Explained to a 5-year old.
Tinder+AI: A perfect Matchmaking?
An insider’s guide to Cartoonization using Machine Learning
How Google made β€œHum to Search?”
One-line Magical code to perform EDA!
Give me 5-minutes, I’ll give you a DeepFake!

Cheers


How I personalized my YouTube recommendation using YT API? was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.

Published via Towards AI

Feedback ↓