网页排序 HITS算法的python实现

该博客介绍了HITS(Hypertext Induced Topic Selection)算法的Python实现,提供了源代码,并指出默认使用的数据文件是pgr_data.txt。读者可以通过修改源代码或使用命令行参数来调整输入数据。
摘要由CSDN通过智能技术生成

算法原理不在赘述,请参考:

http://blog.csdn.net/hguisu/article/details/8013489


将代码保存为.py格式,默认使用的数据是代码文件所在目录下data目录下的 pgr_data.txt 文件分别作为源数据输入。以上参数可以在源代码中修改,也可以使用命令行参数传入,参考以下启动方式:

python hits.py pgr_data.txt

命令中后参数为输入数据的途径。

代码中设立了三个参数,分别为:

size = 100  ### the size of the networks  
times = 200 ### the maxmim times for iterations  
error = 0.0001 ### the error used for stoping the iterations
分别为hits算法的网络的最大节点数,迭代最大次数,最大误差允许。最后两个参数用来限制迭代次数。


python 源代码如下:

__author__ = 'Administrator'
import re
import sys



size = 100  ### the size of the networks
times = 200 ### the maxmim times for iterations
error = 0.0001 ### the error used for stoping the iterations

tr_data = [[0 for i in range(size)] f
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值