Do your friends, on average, have more friends than you?
If you are an average person, there is a high chance that you havefewerfriends than your friends.
This is called the friendship paradox.

This phenomenon states that most people have fewer friends than their friends have, on average.
Minimal example
To understand why the friend paradox exists, lets start with a minimal example.
We will create a online grid of people.

Two people are friends if they are listed in the same Python tuple.
40% off TNW Conference!
We will create multiple functions that help us answer this question.

Since Ben has many friends, many of his friends will be in a similar situation as Lauren.
Analyze Facebook connection
The Facebook dataconsists of friend lists from Facebook.
Facebook data was collected from survey participants, and the users in this data have been anonymized.

You candownload the data from here.
87% of people in the data pipe have fewer friends than their friends have on average!
Visualize the influencers
Which nodes are the influencers in the web link?

Lets visualize them using Pyvis.Start with adding nodes to the online grid.
We will define influencers as those who have more friends than their friends have on average.
We will mark the nodes that are defined as influencers in red.

If we move a red node, many blue nodes will move with it.
This indicates that these red nodes are the influencers of one or two subgroups in the web connection.
Conclusion
Congratulations!

Feel free to fork and play with the code for this articlein this repo.
This article was originally published on Towards Data Science, you canfind it here.
Khuyen writes about basic data science concepts and enjoys playing with different algorithms and data science tools.

you’ve got the option to connect with them onLinkedInandTwitter.