Forum Settings
Forums
New
Dec 27, 2015 12:49 PM
#1

Offline
May 2014
34
How does the recommendation algo work?

Also I think recommendation algos are quite cool and there's a lot of data that can be leveraged.
Reply Disabled for Non-Club Members
Jan 8, 2016 4:52 AM
#2

Offline
Oct 2014
3663
I wanna know this as well
Jan 8, 2016 3:58 PM
#3

Offline
Feb 2014
43
The short answer to this question can be found by looking here: https://github.com/anime-plus/graph/blob/master/src/ControllerModules/UserControllerRecommendationsModule.php . If you don’t understand php code, I will do my best to explain in words.
General Algorithm
In general, to find the score that a recommendation has, go to the anime’s MAL page and click on Recommendations. Find every single anime on those recommendations that are on your list (including plan to watch list) and multiply its score by the number of recommendations it has (1+ the number it says under read recommendations by ? more users). If you have that anime scored, use that number and if it is not scored, use its MAL score. Add by all those numbers and divide by the total number of recommendations for all anime that were on your list to get a weighted average. This is the unweighted score of that anime. To find the weighted score, use: 1.2^(-1*total number of recommendations for all anime that were on your list that was calculated earlier) to get a decimal number. This represents how much of that score goes to your mean (your mean includes if you scored any anime on your plan to watch list. If you’ve scored no anime on your list, 0 is used for the mean). If you take 1-that number you will get the amount that is allocated to the unweighted score and add those together to get your weighted score. This is done for all anime in the database and is then sorted from highest weighted score to lowest (where the anime in the top left corner is #1 and the anime in the top right corner is #2) up to 20.
Examples
For an example, we are going to use the anime Hanada Shounen-shi since it is simple to calculate. Let’s pretend that the only anime that you have on your list that is a recommendation to Hanada Shounen-shi is Mushishi and Gintama, both of which you gave a 10/10 and your mean score is a 7.00. The unweighted score for Hanada Shounen-shi would be: 10*1 (Mushishi) + 10*1 (Gintama) = 20/(1+1)= 10.0. The weight would be equal to 1.2^(-1*(1+1)) = 0.6944 so 69.44% would go to the mean of 7.0 and 30.56% would go to the unweighted score of 10.0. So 0.6944*7+0.3056*10= 7.9168.
Now let’s pretend that you added “Natsume’s Book of Friends” to your plan to watch list and updated your list. The unweighted score now becomes: 8.43*5 (Natsume’s Book of Friend’s MAL score at the time this post is created) + 10*1 (Mushishi) + 10*1 (Gintama) = 62.15/(5+1+1) = 8.87857. The weight would be 1.2^(-1*(5+1+1))=0.279 so 27.9% goes to the mean of 7.0 and 72.1% goes to 8.87857=8.3544.
Special Case #1: General Recommendations
Malgraph (now graph.anime.sc) seems to have some special cases for certain anime where it uses the MAL score instead of the weighted score calculated if that weighted score is low enough. It was most likely done to give recommendations to those that have empty lists and serves as a “shows that everyone needs to see” kind of thing. You can find a list of all shows that are part of this here for all entries with an A beside them. What MALgraph seems to do is add only a certain number of anime to a recommendation list (I’m not sure what this number is, but my best guess is that it’s probably around 200 or 300 UPDATE: I found the formula for this where the code is located and discovered it was [10 * Number of Recommendations displayed] so right it displays 20 recommendations so this number is indeed 200) and if one of those anime is part of that number, the weighted score is used for calculation, if not then its MAL score (unweighted) is used instead. For example, let’s pretend that Hanada Shounen-shi is part of that list (it’s not, of course). For the previous example, it had a score of 8.3544 so it is more than likely part of that 200 and the score of 8.3544 would be used. However, let’s pretend that you completed Natsume’s Book of Friends and gave it a score of ‘1’ and updated your list and your mean score did not change. It’s new unweighted score would be: 3.5714 and it’s new unweighted score would be 4.5283. Since 4.5283 is less than the mean score of 7, it’s obvious that there are at least 200 anime that have a higher score of it so it would not be included, so instead it’s MAL score of 8.18 would be used as its score. You can see the top 20 of these shows by looking at the recommendations of an empty list like: this one.
Special Case #2: Sequels, Movies and other parts of series
As you probably already know, MALgraph groups related series together and have a special way to do recommendations for those. I’m not 100% for how they do these, but based on observations my best guess is that they take the first entry of the series (denoted by the lowest number in the link like how Cowboy Bebop is 1) and calculate the score for that. If that anime is in the top 200/300 that I mentioned earlier, that score is used for the series. If it’s not, then the sequel is calculated next and if it’s within it, that anime’s score is used. For example, if your weighted score for Little Busters is high enough to be in the top 200/300, that score is used, even if the weighted score of Little Busters Refrain is higher, if it’s not then the score for Little Busters Refrain is calculated and if it’s part of it, it would be used. There are some anime that are part of the special case 1 and 2 such as Clannad. For those my best guess is they calculate weighted score of first in series first, then go to the MAL score and if that’s not part of the top number then the sequels are calculated. For example, if Clannad’s weighted score was high enough, it would be used, if not then it’s MAL score of 8.37 would be used. If that’s part of the top either, then Clannad Afterstory’s weighted score would be calculated. If that is part of the 200 its weighted score would be used.
After taking all of the above into account, sort the scores used for each series from highest to lowest and display the first 20! Hope this helps!
Manga Recommendations
There is no actual algorithm for manga recommendations. All that is done is take this list here (seen previously) and look at all entries which start with “M”. Cross off the ones that are already on your list, and sort the remainder from largest MAL score to smallest. If you have all the entries on this list on your own list, you will get no more manga recommendations. Looks like they have recently updated it now. It's basically just the same thing as they do for anime recommendations, except manga and the static recommendations are the M part of the list seen for anime.

TL;DR Look at the first url, the general algorithm or the examples.
justinspatzFeb 16, 2016 9:13 PM

Forum Set Created by uwuglo during the MAL Secret Santa 2020 event.
Jan 9, 2016 5:15 PM
#4

Offline
Oct 2014
3663
So the recommendation algorithm doesn't honor favorite genres and manga recs are just taken from a static list. Got it
CnonJan 9, 2016 5:19 PM
Feb 23, 2016 10:39 PM
#5

Offline
Oct 2014
15425
Ever since I took HxH and FMAB off my PTW I have been getting more accurate recommendations. Thanks for telling me about that. I feel like it should just ignore anime that the user hasn't rated, but for now taking anime that mess with the rec system off my list is a good enough fix for the problem. I do have HxH as a recommendation now, but at least the anime it suggests are in my taste for the most part.
Jul 17, 2016 6:28 PM
#6

Offline
Jun 2012
276
Hey, I'm kinda confused by the "missing titles". Most of them make sense, like sequels, specials, ovas, movies and spin-offs that are related to a franchise. But then, there is Castle in the Sky with the missing titles: Sherkock Hound. Wtf? Yea, I know that these 2 and Nausicaä are some of the most notable and first directory works of Miyazaki, but they have nothing to do with each other otherwise.

Just wondering why this is. I also have a gripe with putting the different versions of Princess Kaguya in the same basket as well. A Studio Ghibli film, a Hello Kitty animation and a Hentai version :| kk.
Welcome to club: Anime that Should Continue
http://myanimelist.net/clubs.php?cid=37045
Jul 17, 2016 10:24 PM
#7

Offline
Oct 2014
15425
DarkMind said:
Hey, I'm kinda confused by the "missing titles". Most of them make sense, like sequels, specials, ovas, movies and spin-offs that are related to a franchise. But then, there is Castle in the Sky with the missing titles: Sherkock Hound. Wtf? Yea, I know that these 2 and Nausicaä are some of the most notable and first directory works of Miyazaki, but they have nothing to do with each other otherwise.

Just wondering why this is. I also have a gripe with putting the different versions of Princess Kaguya in the same basket as well. A Studio Ghibli film, a Hello Kitty animation and a Hentai version :| kk.
There are what I would "specials webs" that connect unrelated anime/manga together. For example, look at this list of manga that it thinks I should read to complete the Aho Girl franchise.

Aho Girl is a standalone manga, but the main girl was featured in the manga "Magazine Heroines on the Beach" which also includes characters from Yamada-kun to 7-nin no Majo, Baby Steps, and Fuuka adding those as relations as well as all the manga related to those titles. Yamada-kun to 7-nin no Majo is featured in another crossover special called "Magazine Ohanami!!" which is where Fairy Tail comes from in the specials web. Specials webs are fairly common with manga, but they do exist with anime too. There are supposed to be things in place to prevent specials webs from doing this to the "incomplete franchises" lists, but there are too many to actively nullify that they still remain.
Nov 5, 2016 4:05 AM
#8

Offline
Sep 2014
372
1 great recommendation from 1 test do thank you.

Slightly curious on two counts:

Where did the 1.2 come from. Was it a trial and error figure?

When comparing unrated shows, could you use the standard dev already available on profile to apportion these in line with the users mean score.

So in the above example.

I don't have the anime used but say I had given the 2 controls ten as per above.

Friends would get an unweighted average of 8.53 even though my average my list average is approx 2.2 lower than mal average. Wouldn't it be more accurate to assign a score of 8.53 times my mean / mal mean to it since right now shows on ptw are likely to have more affect than those I have rated.

I dont know if that would be massively more resource heavy, hard to program or if I'm just being silly and overlooking something but thats just my take.

Edit, scaling factor was incorrect in my suggestion
StarlitSentryNov 5, 2016 4:14 AM

Nov 5, 2016 8:19 PM
#9

Offline
Feb 2014
43
ScarletSentry said:
Where did the 1.2 come from. Was it a trial and error figure?
I don't think anyone on this forum can really provide an accurate answer to this since no one here provided the code for the recommendations, as the people that came up with it were the users fri and rr- who used to run the old MALgraph before they closed it. If I were to guess, I'd say the part of it was from trial and error, though the two have studied statistics a lot so I assume they had an idea for a number based on a percentage for a certain number of recommendations. And of course, 1.2 is a faster number for computations than something like 1.194645665156156456132132156 or something like that.


I’m not really sure how you want to use standard deviation for unscored anime, as standard deviation just tells you whether the majority of your scores are close to your mean or far from it. Not sure how that applies to a MAL score of an anime as a larger standard deviation just tells you that it’s more likely to be different (though unsure if in positive or negative direction). Perhaps you meant mean deviation?


I’m not 100% if I’m understanding your suggestion correctly, though I’m guessing what you are saying is that for unscored anime have it so their impact is equal to their MAL score * (your MAL score divided by MAL’s database mean score)? Not bad, though I think it’d be easy for someone that has a MAL score higher than the MAL’s database to have certain anime be scored above a 10 which would be ridiculous (unless you set a max of 10 and min of 1). Also, will probably be very resource heavy since there are about 8000 anime in the database… There is a global mean score though it’s not the same.

Forum Set Created by uwuglo during the MAL Secret Santa 2020 event.
Nov 5, 2016 8:37 PM

Offline
Sep 2014
372

Ye I meant the global mean score. Also I only realised after that the global score in MALgraph is different to the average across MAL (guessing this is the average across your user database?). You don't actual have to use standard dev since you already have user's mean and global mean, that one's on me

The 1.2 is curious to me but not massively concerning. It put's an extra slant towards anime with a higher number of recommendations which is slightly biased towards anime with higher popularity but countering this would be a pain to model and possibly counter-productive anyway since, presumably, more popular anime will make hit more accurately as recommendations. On a side note for those wondering, having a low average is more likely to make your list more personalised to your individual scores owing to how this term acts on your overall average.)

The 2nd half uses unrated PTW as the MAL mean which strikes me as slightly odd since it means that PTW will likely have a greater affect on those with a lower average while having lesser effect on those with a higher average. Multiplying by the term I mentioned would diminish this effect and roughly adjust the MAL average to your scale. Also I understand why a score greater than 10 might seem absurd but mathematically it wouldn't actually break the formula in the slightest. It certainly does potentially make PTW to dominant in high average scales though too.

Anyway don't worry about it, I'm not necessarily suggesting you change anything, just wondering what ye are using and why out of curiosity.
StarlitSentryNov 5, 2016 8:49 PM

Nov 5, 2016 9:25 PM

Offline
Feb 2014
43


Yeah it's the average across MALgraph's userbase (seems to be weighted too).

Eh, I think it's good to have it weighted to skew to more popular anime, since there is a bias against them in that they have more recommendations to different kinds of anime compared to unpopular anime like how Mushishi have recommendations to over 50 different kinds of anime while Hanada Shounen-shi only has 6 so even if you give Natsume's Book of Friends a 10, it many not be necessarily more skewed to Mushishi since Mushishi has plenty of other anime that you maybe have given a 7 or 8 to lower its recommendation score. I think the bigger concern are anime that have a bunch of recommendations for only 1 anime and barely any for others so they are not affected by either, like Gokusen :/

I definitely agree with you on your second point since I've seen many users' recommendations based on anime they haven't even watch an episode of (myself included). The thing I thought of was to take those values in the diff column under the anime list tab (the green and red ones) and finding a mean for that and applying it to the MAL scores (max of 10, min of 1). Though maybe there are better ways?

Yeah, don't worry, this is just a thread to discussing the recommendations since there is a thread already dedicated to making suggestions, so I'm just discussing with you. I have absolutely nothing to do with the recommendation code, I only know how it works. Don't think there is much of a chance of changes anyways as since Deividas imported the code of the old MALgraph, he hasn't made too many changes to the algorithm. All he has done is changed the amount of anime displayed on the recommendation page from 10 to 20 and he changed the static recommendation list.

Forum Set Created by uwuglo during the MAL Secret Santa 2020 event.
Reply Disabled for Non-Club Members

More topics from this board

Sticky: » Suggestions ( 1 2 3 4 5 ... Last Page )

Deividas - Apr 20, 2015

1398 by _cjessop19_ »»
Oct 2, 6:21 PM

Sticky: » Support ( 1 2 3 4 5 ... Last Page )

Deividas - Apr 20, 2015

754 by Etherious_123 »»
Jul 3, 5:54 AM

Sticky: » Custom List Maintenance

Half_Bl00d - Feb 28, 2017

11 by TheM4ngaMan »»
Feb 3, 4:32 AM

» List of Series Used for the Achievement Badges

Half_Bl00d - May 13, 2020

0 by Half_Bl00d »»
May 13, 2020 6:37 AM

Sticky: » Custom Lists [READ BEFORE POSTING IN CUSTOM LIST MAINTENANCE THREAD]

Half_Bl00d - Mar 1, 2017

4 by Half_Bl00d »»
Mar 1, 2017 2:32 AM
It’s time to ditch the text file.
Keep track of your anime easily by creating your own list.
Sign Up Login