Skip to content

Latest commit

 

History

History
58 lines (42 loc) · 2.15 KB

README.md

File metadata and controls

58 lines (42 loc) · 2.15 KB

social media influencer

this code finds influencers based on some keywords and some experimental pointings that is calculateed based on number of likes, followers, followings, etc. of users and then by networkx package and DiGraph gets pagerank of each user and gives it back to database.

The documentations of main packages are available in following links:

Getting started

calculating each user's threshold(or points):

 ter = (50 * retweets + followers + 100 * followers / followings + comments + likes) / 100
 

getting users that have more than 100 threshold and using some directed weighted graph to achieve pageranks of each users:

relations = []
item = []
for i in range(length):
    if threshold(influencer[i]['_source']['id'])[6] > 100:
        step = 0
        lengthFollowing = len(influencer[i]['_source']['followings'])
        for j in range(lengthFollowing):
            item.append(influencer[i]['_source']['id'])
            item.append(int(influencer[i]['_source']['followings'][j]['id_str']))
            item.append(threshold(influencer[i]['_source']['id'])[6])
            item = tuple(item)
            relations.append(item)
            item = []


# 2. getting users page ranks.
g = nx.DiGraph()
g.add_weighted_edges_from(relations)
pr = nx.pagerank(g)

Notes

you can use this code for finding influencers for a special keyword(i.e. hashtag) if you can get users associated with that keyword from database; the rest is the same.

Requirements

Python 3.8+ is required. The following packages are required:

important links

License

NetworkX is a Python library for studying graphs and networks. NetworkX is free software released under the BSD-new license.