Pages

Showing posts with label facemash algorithm. Show all posts
Showing posts with label facemash algorithm. Show all posts

Sunday, 18 March 2012

Optimization of News Feed in Facebook


The Facemash algorithm that I had posted here was just a “trailer” of this actual post for starting understanding Facebook.

Facebook used basically a data structure,called graph.Graph includes two basic things:

1.Nodes with their corresponding value

2.Edges between nodes with their corresponding weight

Whatever you observe in Facebook mainly is always the News Feed, which is the most important feature of Facebook.

So it is always needed  to carefully choose which posts to publish on the first page of your News Feed. So the main component of your News Feed and at last of your Facebook page is optimization of News Feed.

Below photo shows formula used by Facebook to optimize the News Feed of Facebook profile.



As shown in above photo, the friends and relationships and post by any one of them are based on three parameters:

1.Weight of edge type

2. Time from which they were friends and how ago the post was posted on Facebook

3. How closer the friends i.e. in same school or just a fan of other friend

Thus,the sum of product of all your friends and “weight” of your relationships with them is what you see in the News Feed of your Facebook profile.

So the better you are friends (it can be known by a simple Facebook app,whose making we will discuss later)  the more are the chances that your post will be on the News Feed of other one. Similarly , the more you interact,more is the chance is there that you are featured on the News Feed of your other friend.


 Four Your Information(FYI):

Depending on your number of friends and their activity, a click to your News Feed can call up as many as 10,000 stories that account for about 8 megabytes of space. All this occurs in about seven-tenths of a second.

Sunday, 11 March 2012

Algorithm for facemash


You must be remembering this scene from The Social Network movie,when Eduardo Saverin writes an algorithm for making facemash.com.

Actually,the algorithm is a simple algorithm to rank the players of chess,named Elo rating System.According to wiki:


The Elo rating system is a method for calculating the relative skill levels of players in two-player games such as chess.

Algorithm:

According to this algorithm following represents the expected score of for example,Player A








Similarly the expected score for example,Player B is:


Where RA is current rating of Player A and RB is current rating of player B.

When player A will play the match whatever score he has,it will be compared with the expected score and that will give a new rating for player A. This will be done using the below formula;




Where SA is the actual score of player A. K is a constant that has two values for Master players K=16 and for weaker players K will be 32.

Let us take an example of rating girls as done in the Social Network movie. For example we have the following table:


Girl Current Rating Result Score


A


80




B


90
Lost 0


C


30
Won 1


D


50
Draw 0.5


E


40
Won 1


Now as you can see clearly that A was compared with 4 girls and she has scored 2.5 points. If you calculate the expected score using the above formula it will be as follows :
                    
                     2.157(0.485+0.572+0.543+0.557).

Now using the second formula given above we will calculate the new Rating for player A  using K = 16  will be

                     R’A = 80 + 16(2.5-2.157) = 85.2

That's all about the algorithm.Anything more should be reflected in comments.