A data-driven approach to optimizing political outreach campaigns using network science and community detection algorithms.
For Employers: See EMPLOYER_HIGHLIGHTS.md for a quick summary of skills demonstrated and business impact.
This project applies advanced network analysis techniques to identify influential users and communities within social networks, enabling more efficient and cost-effective political outreach strategies. By leveraging the Facebook ego network dataset from Stanford SNAP, this analysis demonstrates how targeted approaches can achieve 92.2% outreach coverage compared to just 25.2% with random targeting.
- Political Campaigns: Optimize advertising spend by targeting high-influence individuals
- Social Media Marketing: Identify key influencers and community structures
- Information Diffusion: Model and predict how information spreads through networks
- Community Analysis: Understand social group dynamics and relationships
- Structural Metrics: Clustering coefficient (C = 0.51), average path length (L = 3.75)
- Degree Distribution: Identifies hub nodes and network topology
- Small-World Properties: Analyzes network efficiency and connectivity
- Louvain Algorithm: Detects 13 algorithmic communities with varying densities
- Comparison with Ground Truth: Evaluates against user-defined social circles
- Adjusted Rand Index (ARI): Measures alignment between detection methods (ARI = 0.221)
- Degree Centrality: Identifies highly connected influencers
- Betweenness Centrality: Discovers bridge nodes connecting different communities
- Eigenvector Centrality: Finds nodes connected to other important nodes
- Threshold Model: Simulates information spread with configurable activation thresholds
- Targeted vs. Random Seeding: Compares strategic vs. random user targeting
- ROI Analysis: Demonstrates significant efficiency gains with data-driven approaches
New to this project? See QUICKSTART.md for a 5-minute setup guide.
- Python 3.8 or higher
- pip package manager
- Clone this repository:
git clone https://github.com/aymanmomin/Facebook-Ego-Network-Analysis-for-Political-Outreach-Optimization.git
cd Facebook-Ego-Network-Analysis-for-Political-Outreach-Optimization- Install required dependencies:
pip install -r requirements.txt- The dataset is included in the
data/directory (Stanford SNAP Ego-Facebook dataset)
Open and run the Jupyter notebook:
# Main analysis notebook
jupyter notebook cpsc-572-facebook-ego-network-analysis.ipynbOr use JupyterLab:
jupyter labThe notebook is fully self-contained and includes:
- Automatic package installation
- Data loading and preprocessing
- All analysis steps with detailed explanations
- Visualization generation
- 13 Communities Detected: Varying from tight-knit groups (density = 1.0) to loose networks (density = 0.154)
- High-Density Communities: Enable rapid information spread within groups
- Low-Density Communities: Require bridge nodes for effective reach
- Targeted Approach: 92.2% network coverage with strategic seeding
- Random Approach: Only 25.2% coverage with same budget
- Key Finding: Degree centrality is the most effective metric for practical targeting
Critical connectors identified (nodes 277, 175, 19, 23, 25) that link otherwise disconnected communities, essential for cross-community influence.
βββ notebooks/
β βββ facebook-ego-network-analysis.ipynb # Main analysis notebook
βββ data/ # Facebook ego network dataset
β βββ facebook_combined.txt # Combined edge list
β βββ *.edges # Individual ego networks
β βββ *.circles # User-defined social circles
β βββ *.feat # Node features
β βββ network_communities.html # Interactive visualization
βββ visualizations/ # Analysis output images
β βββ day1_results.png # Basic statistics
β βββ day2_results.png # Community detection
β βββ day3_results.png # Influence simulation
β βββ part1_results.png
β βββ part2_results.png
βββ docs/ # Documentation
β βββ README.md # Documentation index
β βββ technical-report.md # Detailed analysis report
βββ requirements.txt # Python dependencies
βββ CONTRIBUTING.md # Contribution guidelines
βββ REORGANIZATION_GUIDE.md # File organization instructions
βββ README.md # This file
βββ LICENSE # MIT License
βββ .gitignore # Git ignore patterns
Note: See REORGANIZATION_GUIDE.md for instructions on organizing files into the recommended structure.
- NetworkX: Graph manipulation and analysis
- Python-Louvain: Community detection
- Pandas: Data manipulation
- NumPy: Numerical computations
- Matplotlib: Static visualizations
- PyVis: Interactive network visualizations
- Scikit-learn: Similarity metrics (ARI)
- tqdm: Progress tracking
- Data Preprocessing: Load ego network, filter isolates, construct graph
- Structural Analysis: Calculate network metrics and compare with null models
- Community Detection: Apply Louvain algorithm and compare with ground truth
- Centrality Computation: Rank nodes by influence potential
- Threshold Simulation: Model information diffusion with activation thresholds
- Strategy Comparison: Evaluate targeted vs. random seeding approaches
This framework can be adapted for:
- Marketing Campaigns: Identify brand ambassadors and influencers
- Public Health: Optimize health intervention programs
- Corporate Communications: Internal information dissemination strategies
- Academic Research: Social network studies and graph theory
- Product Launches: Viral marketing and early adopter identification
Stanford SNAP Ego-Facebook Network
- Source: Stanford Network Analysis Project
- Description: Anonymized Facebook friendship networks from survey participants
- Size: 4,039 nodes, 88,234 edges
- Features: Anonymized profile attributes, user-defined circles
- Citation: J. McAuley and J. Leskovec. Learning to Discover Social Circles in Ego Networks. NIPS, 2012.
Contributions are welcome! Feel free to:
- Open issues for bugs or feature requests
- Submit pull requests with improvements
- Share your use cases and adaptations
This project is licensed under the MIT License - see the LICENSE file for details.
Ayman Momin
- GitHub: @aymanmomin
- LinkedIn: Connect with me
- RESUME_EXAMPLES.md - Ready-to-use resume bullets and LinkedIn posts
- EMPLOYER_HIGHLIGHTS.md - Executive summary for recruiters
- QUICKSTART.md - 5-minute setup guide
- Report.md - Detailed technical analysis
- Stanford Network Analysis Project (SNAP) for providing the dataset
- NetworkX development team for the excellent graph analysis library
- Python open-source community
β If you find this project useful, please consider giving it a star!