Skip to Content
Mastering Marketing Data Science
book

Mastering Marketing Data Science

by Iain Brown
April 2024
Beginner to intermediate
432 pages
12h 45m
English
Wiley
Content preview from Mastering Marketing Data Science

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:

  1. Visualize the Social Network:
    • Use networkx to create a visual representation of the network.
    • Highlight key nodes that might represent influential users.
  2. Calculate Centrality Measures:
    • Calculate degree, betweenness, and eigenvector centrality for each node.
    • Identify top five influential users based on these centrality measures.
  3. Discussion:
    • Discuss how these measures can help in identifying potential influencers for marketing campaigns.
    • What are the limitations of this approach?

Steps:

  1. 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.

  2. 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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Data Science for Business

Data Science for Business

Foster Provost, Tom Fawcett
Data Science for Marketing Analytics - Second Edition

Data Science for Marketing Analytics - Second Edition

Mirza Rahim Baig, Gururajan Govindan, Vishwesh Ravi Shrimali

Publisher Resources

ISBN: 9781394258710Purchase Link