## 2 Materials and Methods
### Feature Selection
In order to improve the classification speed, we use the AVX instruction set to realize the simultaneous calculation of multiple feature value distances and reduce the instruction consumption of kNN, so as to improve the performance of the kNN algorithm and meet the requirements of fast classification of massive texts. Figure 2 shows the procedure of the text classification algorithm accelerated with the use of AVX-256, which is elaborated in Algorithm 2 with a step-by-step explanation of the procedure. ```
Input: trainSet, testText, keywordList Output: type
1. keywordList = LoadKeyword()
2. for i = 1 to trainSet.length
3. Load_trainText (trainSet.text[i], keywordList)
4. Calc_weight(keywordList)
5. for i = 1 to trainSet.length
6. trainSet.vector[j] = Get_featureVector (trainSet.text[i], keywordList)
7. featureVector = Get_featureVector(testText, keywordList)
8. for i = 1 to trainSet.length
9. neighbor[i].distance = CalculateDistance(featureVector, trainSet.vector[i])
10. neighbor[i].type = trainSet.type[i]
11. k_nearest_neighbor = sort_k(neighbor)
12. type = k_nearest_neighbor.most_type
```

**Algorithm 2** text classification based on AVX-256

Figure 2: The procedure of text classification algorithm with AVX-256 acceleration. Extract the feature vector of the text to be classified
* 8 Go through the training set. * 9 Calculate the distance between the text to be classified and the _i_th training text. * 10 Obtain the classification type of the _i_th training text. * 11 Sort by neighbor distance. * 12 Identify the target document category based on the category of the k-nearest neighbors. ### Text Classification Algorithm Optimization Based on AVX-256

Computer instructions can be divided into scalar instructions and vector instructions [39], where scalar instructions can only operate on one data point at a time. As the core technology of vector instruction, SIMD can use one instruction to process multiple data points in parallel. Compared with traditional single data instructions, SIMD has fine parallelism and can increase the computation speed exponentially in data-intensive matrix vector operations. For traditional kNN classification calculations, scalar instruction is still used in floating-point calculations, which wastes vector computation resources in the CPU. SIMD technology can be used to achieve efficient utilization of CPU computing resources. AVX-256 can process eight 32-bit data at a time, increasing the Euclidean distance calculation speed by nearly 4-8 times. Assuming that the dimensionality of the document feature vector is \(n\) and the number of samples in the training set is \(p\), the arithmetic complexity of kNN is O(_n*p_), while the arithmetic complexity after optimization by AVX is O(_n*p_/4). Based on AVX-256, vector construction and operation can be realized; thus, the kNN text classification algorithm is optimized. This method can realize the simultaneous calculation of multiple feature value distances and reduce the instruction operation consumption of kNN, so as to improve the efficiency of the kNN algorithm and meet the fast classification requirements of large-scale texts. In the dictionary, the number of keyword occurrences in each text can be represented by a 32-bit wide number, and an AVX instruction can simultaneously achieve eight feature parameter operations for AVX-256, supporting 256-bit wide vector operations. 1. Occurrence vector construction: Use the instruction _mm256_loadu_ps to construct a vector, which includes the occurrence of a keyword in eight documents. 2. Calculation of characteristic parameter _ej_: Through _mm256_div_ps and _mm256_log2_ps instructions to achieve vector division and log calculation, the calculation of eight values is completed in each operation. 3. Calculation of characteristic parameter _E_: By _mm256_add_ps instruction, the addition of vectors is realized and the information entropy \(E\) within the category is calculated.