Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,191 @@
|
|
1 |
-
---
|
2 |
-
license: mit
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: mit
|
3 |
+
task_categories:
|
4 |
+
- tabular-classification
|
5 |
+
language:
|
6 |
+
- en
|
7 |
+
tags:
|
8 |
+
- social-media
|
9 |
+
- spam-detection
|
10 |
+
- facebook
|
11 |
+
- cybersecurity
|
12 |
+
- machine-learning
|
13 |
+
- binary-classification
|
14 |
+
- fraud-detection
|
15 |
+
size_categories:
|
16 |
+
- n<1K
|
17 |
+
---
|
18 |
+
|
19 |
+
# Facebook Spam Detection Dataset
|
20 |
+
|
21 |
+
## Dataset Summary
|
22 |
+
|
23 |
+
This dataset contains **600 Facebook profiles** with behavioral and activity features designed for **spam detection** in social media. The dataset enables binary classification to distinguish between spam accounts (Label=1) and legitimate accounts (Label=0), providing insights into spammer behavior patterns on Facebook.
|
24 |
+
|
25 |
+
## Dataset Details
|
26 |
+
|
27 |
+
- **Total Samples**: 600 profiles
|
28 |
+
- **Classes**: Binary (0 = Legitimate, 1 = Spam)
|
29 |
+
- **Class Distribution**: Imbalanced (17.2% spam, 82.8% legitimate)
|
30 |
+
- **Features**: 14 behavioral characteristics + 1 target label
|
31 |
+
- **Format**: CSV file
|
32 |
+
|
33 |
+
## Features Description
|
34 |
+
|
35 |
+
| Feature | Type | Description | Range |
|
36 |
+
|---------|------|-------------|-------|
|
37 |
+
| `profile id` | Integer | Unique profile identifier | 1-600 |
|
38 |
+
| `#friends` | Integer | Number of friends | 4-5,554 |
|
39 |
+
| `#following` | Integer | Number of accounts being followed | 1-5,312 |
|
40 |
+
| `#community` | Integer | Number of communities/groups joined | 12-1,789 |
|
41 |
+
| `age` | Integer | Account age (likely in days) | 125-2,697 |
|
42 |
+
| `#postshared` | Integer | Total number of posts shared | 76-3,896 |
|
43 |
+
| `#urlshared` | Integer | Number of URLs shared in posts | 11-2,956 |
|
44 |
+
| `#photos/videos` | Integer | Number of photos/videos posted | 65-3,891 |
|
45 |
+
| `fpurls` | Float | Frequency/proportion of URLs in posts | 0.01-1.09 |
|
46 |
+
| `fpphotos/videos` | Float | Frequency/proportion of media content | 0.0-2.74 |
|
47 |
+
| `avgcomment/post` | Float | Average comments per post | 0.0-665 |
|
48 |
+
| `likes/post` | Float | Average likes per post | 0.1-2.8 |
|
49 |
+
| `tags/post` | Integer | Tags used in posts | 10-99 |
|
50 |
+
| `#tags/post` | Integer | Number of tags per post | 1-32 |
|
51 |
+
| `Label` | Integer | **Target variable** - Spam (1) or Legitimate (0) | 0-1 |
|
52 |
+
|
53 |
+
## Key Statistics
|
54 |
+
|
55 |
+
- **Network Size**: Average 1,066 friends and 1,069 following
|
56 |
+
- **Community Engagement**: Average 208 communities joined
|
57 |
+
- **Account Maturity**: Average age of 1,215 days (~3.3 years)
|
58 |
+
- **Content Activity**:
|
59 |
+
- Average 1,158 posts shared
|
60 |
+
- Average 370 URLs shared
|
61 |
+
- Average 1,121 photos/videos posted
|
62 |
+
- **Engagement Metrics**:
|
63 |
+
- Average 1.6 comments per post
|
64 |
+
- Average 0.88 likes per post
|
65 |
+
- Average 16 tags per post
|
66 |
+
|
67 |
+
## Class Imbalance
|
68 |
+
|
69 |
+
⚠️ **Important**: This dataset is imbalanced:
|
70 |
+
- **Legitimate accounts**: 497 samples (82.8%)
|
71 |
+
- **Spam accounts**: 103 samples (17.2%)
|
72 |
+
|
73 |
+
Consider using techniques like SMOTE, class weighting, or balanced sampling for training.
|
74 |
+
|
75 |
+
## Use Cases
|
76 |
+
|
77 |
+
This dataset is ideal for:
|
78 |
+
|
79 |
+
- **Spam Detection**: Build classifiers to identify Facebook spam accounts
|
80 |
+
- **Behavioral Analysis**: Study differences between spam and legitimate user behavior
|
81 |
+
- **Anomaly Detection**: Develop unsupervised methods for suspicious activity detection
|
82 |
+
- **Social Media Security**: Research automated content moderation systems
|
83 |
+
- **Imbalanced Learning**: Practice techniques for handling skewed datasets
|
84 |
+
|
85 |
+
## Quick Start
|
86 |
+
|
87 |
+
```python
|
88 |
+
import pandas as pd
|
89 |
+
from sklearn.model_selection import train_test_split
|
90 |
+
from sklearn.ensemble import RandomForestClassifier
|
91 |
+
from sklearn.metrics import classification_report, confusion_matrix
|
92 |
+
from imblearn.over_sampling import SMOTE
|
93 |
+
|
94 |
+
# Load dataset
|
95 |
+
df = pd.read_csv('Facebook Spam Dataset.csv')
|
96 |
+
|
97 |
+
# Prepare features and target
|
98 |
+
X = df.drop(['Label', 'profile id'], axis=1)
|
99 |
+
y = df['Label']
|
100 |
+
|
101 |
+
# Handle class imbalance with SMOTE
|
102 |
+
smote = SMOTE(random_state=42)
|
103 |
+
X_resampled, y_resampled = smote.fit_resample(X, y)
|
104 |
+
|
105 |
+
# Split data
|
106 |
+
X_train, X_test, y_train, y_test = train_test_split(
|
107 |
+
X_resampled, y_resampled, test_size=0.2, random_state=42, stratify=y_resampled
|
108 |
+
)
|
109 |
+
|
110 |
+
# Train model
|
111 |
+
model = RandomForestClassifier(
|
112 |
+
n_estimators=100,
|
113 |
+
class_weight='balanced',
|
114 |
+
random_state=42
|
115 |
+
)
|
116 |
+
model.fit(X_train, y_train)
|
117 |
+
|
118 |
+
# Evaluate
|
119 |
+
y_pred = model.predict(X_test)
|
120 |
+
print("Classification Report:")
|
121 |
+
print(classification_report(y_test, y_pred))
|
122 |
+
```
|
123 |
+
|
124 |
+
## Suggested Approaches
|
125 |
+
|
126 |
+
### Traditional ML
|
127 |
+
- **Random Forest**: Handles mixed data types well
|
128 |
+
- **Gradient Boosting**: XGBoost, LightGBM for performance
|
129 |
+
- **SVM**: With RBF kernel for non-linear patterns
|
130 |
+
- **Logistic Regression**: With proper feature scaling
|
131 |
+
|
132 |
+
### Handling Imbalance
|
133 |
+
- **Sampling**: SMOTE, ADASYN for oversampling
|
134 |
+
- **Cost-sensitive**: Class weights in algorithms
|
135 |
+
- **Ensemble**: Balanced bagging, EasyEnsemble
|
136 |
+
- **Metrics**: Focus on F1-score, AUC-ROC, precision/recall
|
137 |
+
|
138 |
+
### Feature Engineering
|
139 |
+
- **Ratios**: Create engagement ratios (likes/posts, comments/posts)
|
140 |
+
- **Behavioral**: URL sharing patterns, media content ratios
|
141 |
+
- **Network**: Friend-to-following ratios, community participation
|
142 |
+
- **Temporal**: Account age interactions with activity levels
|
143 |
+
|
144 |
+
## Model Evaluation Tips
|
145 |
+
|
146 |
+
Given the class imbalance, prioritize these metrics:
|
147 |
+
- **F1-Score**: Harmonic mean of precision and recall
|
148 |
+
- **AUC-ROC**: Area under the ROC curve
|
149 |
+
- **Precision/Recall**: Especially for spam class (minority)
|
150 |
+
- **Confusion Matrix**: To understand false positives/negatives
|
151 |
+
|
152 |
+
## Data Quality
|
153 |
+
|
154 |
+
- ✅ **Complete Data**: No missing values
|
155 |
+
- ⚠️ **Class Imbalance**: 82.8% legitimate vs 17.2% spam
|
156 |
+
- ✅ **Feature Variety**: Network, content, and engagement metrics
|
157 |
+
- ✅ **Realistic Ranges**: All features show plausible Facebook activity patterns
|
158 |
+
|
159 |
+
## Research Opportunities
|
160 |
+
|
161 |
+
1. **Behavioral Patterns**: What distinguishes spam from legitimate user behavior?
|
162 |
+
2. **Feature Importance**: Which metrics are most predictive of spam accounts?
|
163 |
+
3. **Temporal Analysis**: How does account age correlate with spam likelihood?
|
164 |
+
4. **Network Effects**: Do spam accounts show distinct networking patterns?
|
165 |
+
5. **Content Analysis**: How do URL sharing and media patterns differ?
|
166 |
+
|
167 |
+
## Potential Applications
|
168 |
+
|
169 |
+
- **Social Media Platforms**: Automated spam account detection
|
170 |
+
- **Content Moderation**: Flagging suspicious posting patterns
|
171 |
+
- **User Safety**: Protecting users from spam and malicious content
|
172 |
+
- **Research**: Understanding social media abuse patterns
|
173 |
+
- **Security Systems**: Real-time threat detection algorithms
|
174 |
+
|
175 |
+
## Citation
|
176 |
+
|
177 |
+
```bibtex
|
178 |
+
@dataset{facebook_spam_detection_2024,
|
179 |
+
title={Facebook Spam Detection Dataset},
|
180 |
+
year={2025},
|
181 |
+
publisher={Hugging Face},
|
182 |
+
url={https://huggingface.co/datasets/nahiar/facebook-spam-detection}
|
183 |
+
}
|
184 |
+
```
|
185 |
+
|
186 |
+
## Notes
|
187 |
+
|
188 |
+
- The `age` feature appears to be in days rather than years
|
189 |
+
- Some ratio features (like `fpurls`, `fpphotos/videos`) may exceed 1.0, indicating normalized metrics
|
190 |
+
- Consider feature scaling for distance-based algorithms
|
191 |
+
- The dataset reflects Facebook's ecosystem and user behavior patterns
|