File size: 4,975 Bytes
8e27693
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2441ae1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c8142d9
2441ae1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
de97809
 
2441ae1
 
 
 
 
 
de97809
 
2441ae1
de97809
 
2441ae1
 
 
 
 
 
 
 
 
 
de97809
2441ae1
de97809
2441ae1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
de97809
2441ae1
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
---
dataset_info:
  features:
  - name: sms
    dtype: string
  - name: label
    dtype: int64
  - name: char_len
    dtype: int64
  - name: word_count
    dtype: int64
  - name: punct_score
    dtype: int64
  - name: spam_keywords
    dtype: int64
  - name: lexical_diversity
    dtype: float64
  - name: readability
    dtype: float64
  - name: caps_ratio
    dtype: float64
  - name: digit_ratio
    dtype: float64
  - name: exclaim_ratio
    dtype: float64
  - name: url_flag
    dtype: int64
  - name: spammy_words
    dtype: int64
  - name: entropy
    dtype: float64
  splits:
  - name: train
    num_bytes: 974514
    num_examples: 5171
  download_size: 446788
  dataset_size: 974514
configs:
- config_name: default
  data_files:
  - split: train
    path: data/train-*
---

# SMS Spam Enriched Dataset

An enriched version of the classic **SMS Spam Collection Dataset from UC Irvine** with additional engineered features and semantic embeddings.  
This dataset is designed for **spam detection, feature engineering experiments, and model interpretability research**.

---

## Dataset Overview

- **Total samples**: 5,171  
- **Classes**: 
  - `0`: Ham (non-spam)  
  - `1`: Spam  

---

## Enrichments Added

Alongside the raw SMS text (`sms`) and labels (`label`), we engineered multiple new features:

1. **char_len** β†’ Total characters in the message  
2. **word_count** β†’ Total words in the message  
3. **punct_score** β†’ Weighted score for punctuation usage (`!`, `?`, `...`)  
4. **spam_keywords** β†’ Count of known spammy tokens (`free`, `win`, `urgent`, etc.)  
5. **lexical_diversity** β†’ Ratio of unique words to total words  
6. **readability** β†’ Flesch Reading Ease score  
7. **caps_ratio** β†’ Proportion of uppercase characters  
8. **digit_ratio** β†’ Proportion of numeric digits  
9. **exclaim_ratio** β†’ Ratio of exclamation marks to total characters  
10. **url_flag** β†’ Binary indicator for presence of URLs  
11. **spammy_words** β†’ Count of flagged high-signal words  
12. **entropy** β†’ Shannon entropy of characters  
13. **embeddings** β†’ Sentence-transformer vector representations (for downstream tasks like clustering, semantic similarity, visualization)

---

## Example Row

| sms                                            | label | char_len | word_count | punct_score | spam_keywords | lexical_diversity | readability | caps_ratio | digit_ratio | url_flag | entropy |
|------------------------------------------------|-------|----------|------------|-------------|---------------|-------------------|-------------|------------|-------------|----------|---------|
| "Free entry in 2 a wkly comp to win FA Cup..." |   1   |   156    |    28      |     0       |      3        |       0.857       |    80.83    |   0.064    |   0.16      |    0     |  4.69   |

---

## Visualizations

Below is a **PCA projection** of SMS embeddings, showing clear separation between spam (red) and ham (blue):  

![PCA Plot](https://huggingface.co/datasets/GenAIDevTOProd/sms-spam-enriched/blob/main/PCA%20project%20of%20sms%20embeddings.png)

---

## Benchmark Models

We trained baseline classifiers using the enriched dataset:

- **Logistic Regression (with combined features)**  
  - Accuracy: ~99%  
  - F1 (spam): ~0.95  

- **Random Forest (with combined features)**  
  - Accuracy: ~98%  
  - F1 (spam): ~0.92

  Logistic Regression Report (Combined Features):

  
              precision    recall  f1-score   support

           0       0.99      1.00      0.99       904
           1       0.98      0.92      0.95       131

    accuracy                           0.99      1035

  
   macro avg       0.99      0.96      0.97      1035

  
weighted avg       0.99      0.99      0.99      1035


Random Forest Report (Combined Features):
              precision    recall  f1-score   support

           0       0.98      1.00      0.99       904
           1       0.99      0.86      0.92       131

    accuracy                           0.98      1035
    
   macro avg       0.99      0.93      0.96      1035
   
weighted avg       0.98      0.98      0.98      1035

---

## Use Cases

- Spam detection model training  
- Feature engineering demonstration  
- Embedding-based similarity and clustering tasks  
- Educational material for NLP + ML pipelines  

---

## Citation

If you use this dataset, please cite the original SMS Spam Collection dataset:  

> @inproceedings{Almeida2011SpamFiltering, title={Contributions to the Study of SMS Spam Filtering: New Collection and Results}, author={Tiago A. Almeida and Jose Maria Gomez Hidalgo and Akebo Yamakami}, year={2011}, booktitle = "Proceedings of the 2011 ACM Symposium on Document Engineering (DOCENG'11)", }.  

> Dataset Enrichment and Feature Engineering contributions by Naga Adithya Kaushik (GenAIDevTOProd). 
---

## License

This dataset is distributed under the same terms as the original SMS Spam dataset (publicly available for research).  

---