front_back_link.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:PolBotCheck 作者: codeforfrankfurt 项目源码 文件源码
def follower_botness(username):
#given a username, it creates the histogram of the botness of the followers 
#and saves it in plots (for now)  it also returns the probable percentage of follower bots
#(cutoff needs to be defined, for now it is 0.7)""" 
    cutoff = 0.7
    scorelist = []
    followers = db.getFollowers(toName=username)
    for f in followers:
        follower = f['_from'].split('/')[1]
        score = db.getUser(follower)['botness']['score']
        scorelist.append(score)

    if scorelist:
        scores = pd.Series(scorelist, name='probability of follower bot') 
        ax = sns.distplot(scores) 
        fig = ax.get_figure()
        fig.savefig('testfig.png')
        botpercent = sum(np.array(scorelist)>cutoff) / len(scorelist)
        return botpercent
    else:
        return None
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号