Song Recommendation Using Machine Learning

Abdul Baasith
4 min readAug 28, 2021

--

Building a recommendation system is a common task that is faced by Amazon, Netflix, Spotify and Google. The underlying goal of the recommendation system is to personalize content and identify relevant data for our audiences. These contents can be articles, movies, games, etc

In our one lets try if for a song recomendation

The Simplest approach: Popularity and there are some other approaches where we see the purchase history and many

Pros:
Personalized: Considers user info & purchase history Features can capture context: Time of the day,
history: Age of user

How to evaluate a model

precision

so when we’re thinking about precision we’re thinking about basically how much garbage do I have to look at compared to the number of items that I like. So, it’s a measure of when I have a limited attention span

recall

Recall is how many of the true positives were found, how many of the correct hits were also found

Well, we know that we’d like precision and recall both to be as large as possible and what’s the best that it can be

Well like I said, we want precision and recall to be as large as possible but one thing we can measure to compare these is in general, which one is doing better than the other
Well, we can think about the area under the curve. So we can look at for example, all this area under this blue curve or line and compare with orange

Lets try this in a real world example

First step is to get the dataset from this Sframe Click

Next

load the data set

Next

get the summary and check for the number of unique users using their id’s

Next

Building the recommendatory system for popularity model , by splitting test and train dataset

Next

its time to check the recommendation of the model that we build

for first user

For second user

See both the user got the same songs this is when it uses the popularity model we did not target for specific user now lets target for specific user

Well, everybody gets recommended exactly the same things. Because we just recommended the most popular items. So this person also gets recommended Harmonia, Bjork, Dwight Yoakam, King of Leon, so basically, not that exciting. Everybody gets recommended the same things. This is a problem with this model.

Next

now lets do a personalized recommender

Next

its time to check the personalized recommendation of the model that we build

for first user

for second user

Next

we can also see the songs that are similar

we can also take a song and ask what other songs are similar, are liked by similar people. So people who like the song also like this other song, so we can do that by personalized_model.get_similar_items

Next

evaluation of the model

see the personalized model has a good precision and recall

Next

unique users for specific artists

Next

next try to recommend the a set of user with their songs

next run the model

link for github repo

https://gist.github.com/baasithshiyam/043d15d2219a74f81a44f35068d1d072

Done

Hope the tutorial was helpful. If there is anything we missed out, do let us know through comments.😇

❤️❤️❤️❤️❤️❤️❤️Thanks for reading❤️❤️❤️❤️❤️❤️❤️❤️

--

--

Abdul Baasith
Abdul Baasith

Written by Abdul Baasith

Hi there i'm Abdul Baasith, A passionate Software Engineer . If your tool is a hammer then every problem look like a nail

No responses yet