Social media platforms are flooded with fake accounts (bots) that:
- Spread misinformation
- Manipulate trends
- Inflate engagement artificially
Manual detection is impossible at scale.
This project builds an automated detection system using:
- Graph Analytics (main approach)
- Machine Learning (enhancement)
Detect fake accounts using graph structure first, then improve accuracy using machine learning.
fake_account_project/
│
├── data/
│ └── dataset.csv
│
├── generate_data.py
├── graph_build.py
├── feature_engineering.py
├── model.py
└── main.py
- 5000 users (2500 bots, 2500 real)
- Synthetic but realistic behaviour
- High retweets & mentions
- Low followers
- New accounts
- Moderate activity
- Higher followers
- Older accounts
- Each user = Node
- Interaction = Edge
Edges are created using:
- Retweet behaviour
- Mention behaviour
| Metric | Meaning | Bot Pattern |
|---|---|---|
| PageRank | Importance of user | Low |
| In-degree | Incoming links | Low |
| Out-degree | Outgoing links | High |
| Clustering | Community connectivity | Low |
graph_score = follower_retweet_ratio
+ pagerank
- mention_retweet_ratio
- Low score → Bot
- High score → Real user
Accuracy: ~87%
- 1500+ communities detected
- Many isolated nodes
Bots are mostly isolated
Real users form connected clusters
- follower_retweet_ratio
- mention_retweet_ratio
- account_age_days
- hashtags presence
- Random Forest
- Gradient Boosting
- Logistic Regression
| Method | Accuracy |
|---|---|
| Graph Detection | ~87% |
| Random Forest | ~98% |
| Gradient Boosting | ~98% |
| Logistic Regression | ~97% |
Graph gives structure
ML improves accuracy
pip install pandas networkx scikit-learn matplotlib
python generate_data.py
python main.py
- Synthetic dataset
- Approximate graph
- No temporal behaviour analysis
- Real Twitter API data
- NLP features
- Temporal analysis
- Real-time detection
- Python
- NetworkX
- scikit-learn
- pandas
- matplotlib