Giter VIP home page Giter VIP logo

pagerank's Introduction

# PageRank
MapReduce & Transition Matrix

Basic theories behind PageRank:
      1. More important websites are likely to recieve more links from other websites;
      2. Websites with higher PageRank will pass higher weight;
      
How to represent the directivity between pages => Transition Matrix. For instance: Website A links to B, C, D; B links to A,    D; C links to A; D links to B, C;
                To\From    A     B     C     D 
A -> B C D          A      0    1/2    1     0                                   0   1/2  1  0
B -> A D            B     1/3    0     0    1/2        =>  Transition Matrix =  1/3   0   0 1/2
C -> A              C     1/3    0     0    1/2                                 1/3   0   0 1/2
D -> B C            D     1/3   1/2    0     0                                  1/3  1/2  0  0

How to represent the importance of each website => initialize with a number as PR0, in this project use 1/numbers of websites.

  PR1 = PR0 * transition matrix  PR2 = PR1 * transition matrix ... PRN = PR(N-1) * transition matrix.
  This will finally converge, because the important page will get a obvious higher than these pages which are not so important
  
Some corner cases:
        Dead ends: a page that contains no internal links to other pages, and the PR matrix will lose weight every step then finally become more and more close to zero;
        Spider Traps: a page only contains link to itself. and the PR matrix will be dominated by one page and become 1 for that page but others' 0;
        
To avoid these above => PRN = (1 - a) * PR(N - 1) * Transition Matrix + a * e;


Based on the theory above, let's implement on MapReduce! 

	And the first question need to be sloved is what is the input? The Matrix? 

		No, one reason is the transition matrix is sparse matrix, resulted from the number of links in one page is much more tiny compared to the amount of pages, and this result in space waste; 
	    	    another reason is when new page comes or is need to remove, it is pretty difficult to insect or delete this informations onto the matrix.

		Then the actual imput format for transition matrix is one page followed by the pages it links to, e.g. 1  2,7,8,29.  The input for PR0 is the page with 1/6012, which means the amount of pages;


	With declaration of the input files clearly, the next question come into mind is how to calculate the matrix product?

		The amount of the page is so huge that it is too difficult to calculate the matrix product in memory, and is almost impossible for the hardware technology so far.

		We need two MapReducers to complete this processing, and the first MapReducer also needs two mappers, one for transition matrix cell, one for PR matrix cell and the reducer of it calculate the product of matrix cell and PR cell.

		The second MapReducer is to sum all cells together for each page.


The workflow is showed as below:

                  MR1.mapper1           +           MR1.mapper2         =>                    MR1.reducer            =>                MR2.mapper                 =>                  MR2.reducer
1 2,7,8,29       key: 1 | Value: 2=1/4
                 key: 1 | Value: 7=1/4
		 key: 1 | Value: 8=1/4
		 key: 1 | Value: 28=1/4
                       ...
1 1/6012                                      key: 1 | value: 1/6012             1 | 2=1/4, 7=1/4, 8=1/4, 28=1/4 1/6012         Key: 2 | Value: 1/4 * 1/6012
                                                      ...                                         ...                           Key: 7 | Value: 1/4 * 1/6012                calcul all values of the same key
																Key: 8 | Value: 1/4 * 1/6012
																Key: 28 | Value: 1/4 * 1/6012
																             ...

pagerank's People

Contributors

u5years avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.