# A Study of Discriminatory Speech Classification Based on Improved Smote and SVM-RF
## 3 Data and Methods
### Model Construction and Integration  
Figure 6 illustrates the tasks of model construction and optimization, including dataset division, model construction, and model evaluation and optimization. These are described as follows:  
1. Split dataset: the preprocessed dataset is divided into training and test sets, which are used for model training and model evaluation, respectively.
2. Training and integration: the training data are applied to SVM and RF classifiers, respectively, to obtain the model classification results and calculate the correct rate. The correct rate is used to calculate the integrated weights of the model as shown in Equations (1) and (2), and finally the model classification results are weighted and summed to obtain the final classification results.
3. Evaluation and optimization: the accuracy, recall, and F1 score of the model are calculated to evaluate and optimize the model.  
The formula for calculating the weights is as follows:  
Firstly, the index value of each element in the correct rate Z of the classification results of SVM and RF is calculated, and in order to improve the numerical stability, the maximum value in the vector Z is subtracted first, and then the exponential operation is performed to avoid the overflow of the exponential value, as in Equation (1)  
\[exp(z_{i})=e^{z_{i}-max(z)},i=1,2,...,n \tag{1}\]  
Then the exponential values are normalized as in Equation (2)  
\[softmax(z_{i})=\frac{exp(z_{i})}{\sum_{1}^{n}exp(z_{i})},i=1,2,...,n \tag{2}\]  
where \(n\) is the number of label category.  
\begin{table}
\begin{tabular}{c c c c} \hline \hline  & **Original Data** & \
\begin{tabular}{c} **After Filtering by** \\ **Topic Model** \\ \end{tabular} &
\begin{tabular}{c} **After Oversampling** \\ **by SMOTE** \\ \end{tabular} \\ \hline Number & 25,726 & 16,726 & 29,850 \\ \hline \hline \end{tabular}
\end{table}
Table 2: Number of data.  
Figure 6: Model construction and optimization.  
Specifically, the integration method does not use the stacking method. SVM and RF are used to obtain the probabilities of discrimination and non-discrimination predicted by a sample, respectively, and then the final probabilities are obtained by weighted summation. If the probability of discrimination is large, the text will be judged as discriminatory speech, where the weights are obtained by Equations (1) and (2).  
The metrics we used to evaluate our model are common classification task metrics (e.g., precision, recall). For model optimization, we mainly used the Grid Search cross-validation (Grid Search CV) method to optimize the performance of SVM and RF. Our optimization goal is to adjust the parameters of SVM and RF to achieve better performance. For the parameters of SVM, we set two kinds of kernels: linear and radial basis function (rbf), and three values of regularization parameter C were set: 0.1, 1, and 10. For RF, we set the number of trees (n_estimators) to 100 and 200, and the maximum depth of the tree (max_depth) to none, 10, and 20, with none representing no depth limit. We used 5-fold cross validation, performed a parameter search via Grid Search CV, and recorded the parameter search time, model fitting time, and the best parameter combination determined based on the mean test scores in cross validation, as shown in Figures 7 and 8. Through optimization, SVM and RF can achieve the best prediction performance with specific parameter settings: for SVM, using (C = 1) and a linear kernel; for RF, utilizing (n_estimators = 100) and no limit on max_depth