# Enhancing Detection of Arabic Social Spam Using Data Augmentation and Machine Learning
## 3 Proposed Framework for Enhancing Arabic Spam Detection
### Applying Data Augmentation to Collected Data  
In this section, the method for dataset augmentation will be explained. The goal of this phase is to avoid overfitting on the data level, increase the model's generalization, and address the class imbalance problem [19]. By increasing the diversity of training samples, the model will be able to learn more fundamental features of the data, leading to a high-quality classifier.  
Therefore, this phase aims to increase the total number of instances that represent spam training data to improve the accuracy of the model. Word embedding [20] was used as a substitution method, which changes a word by its similarity to its synonyms. Furthermore, AraVec word vectors ([PERSON] et al. [63]) were employed, which is a pre-trained model available for two Arabic content domains: Wikipedia and Twitter and it is based on the [PERSON] et al. [64]. Skip-gram and CBOW versions with 100- and 300-dimensional vector sizes were provided for each domain. We employed the 300-dimensional CBOW vectors  
Figure 1: Proposed Framework for Enhancing Arabic Spam Detection (DASD).  
(AraVec-TWI), which have a wide coverage of different dialect terminology used in random Arabic geolocations.  
To apply a similarity replacement on a given text, two steps are required for the Arabic text data augmentation process, as shown in Figure 2. The first step is to identify the word in the tweet to be replaced, and the second step is to select the appropriate replacement based on AraVec.  
**Step1:** The word to be replaced is one of the tokens that have been used in the tweet. Therefore, in this step, all tokens for each tweet are extracted. Next, it is important to decide the number of tokens to be replaced that are not stop words. Therefore, it is significant to quantify the chunk of the sentence to be replaced, i.e., ratio (\(R\)) of tokens that should be replaced [65]. Therefore, different experiments have been applied and it was found that the best result was obtained when a ratio between 50% and 70% of the overall tokens were replaced,  
\[Number\ of\ replaced\ tokens=R*N. \tag{1}\]  
where:  
\(R\) is a random ratio (between 50-70)  
\(N\) is the total number of tokens per tweet without stop words.  
**Step2:** The output of step1 is a set of vectors. Each vector contains a list of different combinations of original tokens that are candidates for replacement. To replace each of the selected tokens with one of AraVec's, a similarity scoring mechanism was applied. A score is set for the similar words selected by identifying the surrounding relatively similar terms for each center word in the replaced tokens. Furthermore, relatively minor adjustments have been made by applying sorting criteria regarding word embeddings source (AraVec's), word similarity thresholds, and fixing the number of generated sentences to the original embedding replacement process applied by [20]. For example, to avoid redundancy in the returned similar word, which will be used in replacement, we have returned the top 10 similar words per token with a cutoff similarity score of 0.5. This was applied to ensure that retrieved similar words are the closest to the selected tokens. Furthermore, we fixed the number of generated sentences per tweet to four. This led to double the number of spam tweets four times, resulting in 1648 spam tweets.  
An example that illustrates the overall process is shown in Figure 3.  
Figure 2: Arabic text data augmentation process.