EXERCISE 7.1: SOCIAL NETWORK ANALYSIS (SNA) IN MARKETING
Objective: To understand the application of social network analysis in identifying influential users in a marketing context.
Tasks:
- Visualize the Social Network:
- Use networkx to create a visual representation of the network.
- Highlight key nodes that might represent influential users.
- Calculate Centrality Measures:
- Calculate degree, betweenness, and eigenvector centrality for each node.
- Identify top five influential users based on these centrality measures.
- Discussion:
- Discuss how these measures can help in identifying potential influencers for marketing campaigns.
- What are the limitations of this approach?
Steps:
- Load the Data and Import Libraries:
1. import matplotlib.pyplot as plt
2. import networkx as nx
3. sna_data = pd.read_csv("/data/Social_Network_Analysis_Data.csv")
This line imports the matplotlib and networkx library and loads the social network data from the CSV file into a pandas DataFrame.
- Create the Graph:
4. G = nx.Graph()
5. for index, row in sna_data.iterrows():
6. G.add_node(row[‘User’], followers=row[‘Followers’], engagement_rate=row[‘Engagement Rate’])
Here, we create an empty graph using networkx and then add nodes (users) from the DataFrame. Each node is added with attributes ‘followers’ and ‘engagement_rate’. The graph currently has 25 nodes. Here are the attributes for the first five nodes:
- User 0: 2,832 followers, 5.93% engagement rate
- User 1: 3,364 followers, 6.03% engagement rate ...
Get Mastering Marketing Data Science now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.