Facebook News Feed Algorithm Formula

I asked to make the existing core news code in PHP a little smarter. Perhaps with relevance and variety. The client is not self-confident, he just wants something smart (sort of) like a Facebook news feed. I found this (maybe outdated, but has some tips)

enter image description here

Where:

Sigma is the sum of each individual rib. An edge is a story that can appear in your news feed, for example, status update, comment, like, tag, etc.

u is the affinity estimate. This is a factor that weighs how close you are to the person conducting the wiring. If you often interact with a person’s post, have several friends in common, or are related to each other, Facebook is more likely to give this content more weight.

w - . Facebook. , , , , -, .

d - . , , , . Facebook , .

, , :

function calculateFeedScore (){
    foreach ($edges as $edge){
        $friendshipWeight = 30 // pre calculated from the DB
        if ($edgeType = comment) $edgeWeight = 1;
        if ($edgeType = like) $edgeWeight = 2;
        if ($edgeType = tag) $edgeWeight = 3;
        .....
        $edgeAgeInDay = ...; // decay each day
        $decay = 0.5 // Radioactive  decay ??
        $edgeDecayFactor =  1 * pow($decay ,$edgeAgeInHour+1 )  // decay after one day 
        $edgeScore = friendshipWeight  * $edgeWeight  *$edgeDecayFactor  
        $feedItemScore += $edgeScore;

     }
    return $feedItemScore
}

u, w d. ? ? , , Production, ... .

+4

Source: https://habr.com/ru/post/1620954/


All Articles