All pastes #801026 Raw Edit

Something

public python v1 · immutable
#801026 ·published 2007-11-28 22:31 UTC
rendered paste body
import cPickleimport MySQLdbfrom db import DataBasefrom pageRank import pageRankdb=DataBase();dbConn=db.db;dbCursor=db.cursordbCursor.execute("SELECT pl_from, page_id FROM pagelinks INNER JOIN page ON pagelinks.pl_title = page.page_title")wikipedia_links = dbCursor.fetchall()dbCursor.close();del dbCursorsparse_matrix, these_links, last_link_from = [], [1], 1for link_from, link_to in wikipedia_links:    if link_from != last_link_from:        sparse_matrix.append(these_links)        while link_from != last_link_from+1:            sparse_matrix.append([])            last_link_from += 1        these_links = [int(link_from)]    if link_to <= wikipedia_links[-1][0]-1:            these_links.append(int(link_to))    last_link_from = link_frompage_rank = pageRank(sparse_matrix, alpha=.85, convergence=.9)f=open("pagerank.pkl", "w")cPickle.dump(page_rank, f, 1)f.close()"""OUTPUT:Warning: overflow encountered in reduce>>> page_rank[0:100]array([ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,        0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,        0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,        0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,        0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,        0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,        0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,        0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.], dtype=float32)>>>"""