A feature selection approach based on term distributions

Feature selection has a direct impact on text categorization. Most existing algorithms are based on document level, and they haven’t considered the influence of term frequency on text categorization. Based on these, we put forward a feature selection approach, FSATD, based on term distributions in the paper. In our proposed algorithm, three critical factors which are term frequency, the inter-class distribution and the intra-class distribution of the terms are all considered synthetically. Finally, experiments are made with the help of kNN classifier. And the corresponding results on 20NewsGroup and SougouCS corpus show that FSATD algorithm achieves better performance than DF and t-Test algorithms.

Support vector machine is an effective technique to build classification models from high dimensional data. However, its computational complexity prohibits it from being used on very large training data. On the other hand, it is also difficult to build accurate models from data with a large number of classes. SVM methods map the data to another feature space by a kernel function so that a linear hyperplane can be found to separate the objects from different classes. It is hard for users to understand the internal details and working principles of the SVM classifier as SVM is like a black box.
kNN has been widely used in various types of classification tasks (He et al. 2003). This classification approach has gained its popularity owing to its low implementation cost and high effectiveness. However, kNN has a unique requirement which is the necessity in determining the appropriate value of parameter k.
At the moment, one of the difficulties in automatic text classification is "high dimensionality" property in feature space, which has reached up to tens or hundreds of thousands (Yang and Pedersen 1997). How to reduce the dimensionality of feature space and improve the efficiency and accuracy of classifiers become the most urgent problems to be solved in text categorization (Xu et al. 2008). So feature selection is a very critical step with a great influence on text categorization. And its task is to select the reasonable words, which have good abilities to distinguish categories from original feature space.
At present, some popular feature selection methods, such as document frequency (DF) and mutual information (MI) , are widely used in text categorization. These methods are all feasible in theorem, but their effects are different when they are applied in practices. All of these methods are compared by Shan et al. (2003). The experimental results show that DF has a low algorithmic complexity and it is easy to implement, but its performance is not ideal. And the performance of MI is the worst. It is not difficult to find that such methods almost use DF. In fact, term frequency also has a great influence on feature selection. So far, few effective methods have been proposed from the perspective of term frequency. Wang et al. (2014) proposed a t-Test feature selection approach based on term frequency, but it didn't consider the interactions between categories sufficiently. In addition, n-gram (Liu and Lu 2007) is also used in text categorization and has achieved good results. While in training phase, n-gram always produces large amounts of noisy data which influences the training efficiency severly. And in testing phase, such noisy data also has a negative impact on accuracy. In view of these, we propose a new algorithm-FSATD (Feature Selection Approach based on Term Distributions), in which term frequency, the inter-class and the intra-class distribution of the terms are all considered synthetically.
The remaining of the paper is organized as follows: "Related works" section describes the related work about feature selection metrics, such as DF and t-Test. "FSATD" section proposes our new feature selection method-FSATD and gives a detail description about it. "Experiments setup" section describes the experimental data sets, document representation, classifiers, and performance measures used in our experiments. "Results and discussion" section presents the experimental results and shows the effectiveness of FSATD. Conclusion of the research is presented in "Conclusion" section.

Related works
To deal with massive documents corpus, many feature selection approaches have been proposed. Through feature selection methods, we can select informative words, and then improve the classification accuracy. And its main idea is as follows. Firstly, it uses the feature selection function to compute some important values of each word in feature space. Secondly, it sorts the words in descending order according to above values. And finally, it selects the top N words to construct the feature vector. In this section, we only give definitions of two feature selection methods. And they are DF and t-Test respectively.

Document frequency
Document frequency of a term is the number of documents which contain the term in the dataset. The term can be reserved only when it appears in adequate documents. To reduce the dimensionality of feature space and improve the classification accuracy, the terms whose DF is lower than a certain threshold will be removed from feature space (Xu et al. 2008).
Document frequency is a simple word reduction technology. Due to its linear complexity, it can be easily used in feature selection in face of large-scale corpus.

t-Test
t-Test (Wang et al. 2014) is a feature selection approach based on term frequency, which is used to measure the diversity of the distributions of a term frequency between a specific category and the entire corpus. And it is defined as follows.
Here, tf ki is the average frequency of term t i within the category C k , tf i is the average frequency of term t i in collection D, N k is the document number in category C k , N is the document number in collection D, s i 2 = 1 N −K K k=1,j∈C k (tf ij − tf ki ) 2 , and K is the category number in collection D.
The following two ways are used alternatively when the main features are finally selected.
Generally, the method shown in Eq. (2) is always better than that shown in Eq. (3) for multi-classes problem.

FSATD
In this section, we propose a feature selection approach based on term distributions. The purpose of feature selection is to select the terms whose classification capabilities are stronger comparatively in feature space (Xu et al. 2008). In this algorithm, we measure the classification capability of the term based on the inter-class and intra-class distributions of terms.

Variance
In the field of mathematical statistics, variance is usually used to measure the fluctuation of a set of data, and its value is positive correlated to the degree that a set of data deviates from the average. Its definition is as follows.
For a set of data x 1 , x 2 , x 3 , . . . , x n (n is the number of these data), x is the average of the set of data, which is shown as follows.
Then, the variance of the data set is , and we can get Eq. (5) after simplifying.
From Eq. (5), we can know that when the data distribution is scattered or the fluctuation of a data set is large, the sum of squared the difference between each data and the average is large. And it means the variance is large. Similarly, when the data distribution is centralized, the variance is small. So, the larger the variance is, the bigger the data fluctuation is. That is to say, the data is less stable. And likewise, the data set is stable when the variance is small.
In the paper, variance is used to select features in text classification.

Intra-class distribution of the term.
For a specific term t i , {tf i1 , . . . , tf ij , . . . , tf iN k } is used to express the term frequency in every document within category C k . Here, N k is the number of documents in category C k , and tf ij is the term frequency of t i in document d j . When the variance of {tf i1 , . . . , tf ij , . . . , tf iN k } is small, the fluctuation will be small. And it means the distribution of term t i in category C k is homogeneous. So the classification capability of term t i is strong.

Inter-class distribution of the term.
For a specific term t i , {tf 1i , . . . , tf ki , . . . , tf Ki } is used to express the average frequency in every category. And here, K is the number of categories in collection D, and tf ki is the average frequency of t i within a single category C k . The larger the variance of . . , tf ki , . . . , tf Ki } is, the larger the fluctuation will be. This shows that the inter-class distribution of t i is uneven and the classification capability of term t i is strong.

Term distribution
In this section, feature selection function is constructed based on variance. And some symbols are introduced firstly. tf ij is the times that the term t i appears in document d j , namely, term frequency. tf ki is the average frequency of term t i within the single category C k . The formula is as follows.
where N is the number of documents in collection D, N k is the number of documents in category C k , and I(d j , C k ) is an indicator to discriminate whether document d j belongs to category C k .
tf i is the average term frequency of term t i in collection D, and it is calculated as follows.
Similarly, N is the number of documents in collection D.
According to the definition of variance, we can construct the feature selection function from the following two aspects.

Intra-class distribution of the term.
Generally speaking, the term which has a good ability to distinguish category should have a high term frequency in the category, and the intra-class distribution of the term should be homogeneous. If a term t i appears only in few documents within the single category C k , t i will be hardly selected as main feature no matter how large the term frequency is. So, the more homogeneous the intra-class distribution of the term is, the stronger the classification capability of the term will be. Then we will get Eq. (8) to measure the classification capability of the term.
where |C k | is the number of documents in category C k , tf ij is the term frequency of term t i in document d j , and tf ki is the average frequency of term t i within the single category C k . It is easy to find when the variance of set {tf i1 , . . . , tf ij , . . . , tf i|C k | } is small, the fluctuation is small. And this means that the distribution of term t i in category C k is homogeneous. So the classification capability of term t i is strong.
Inter-class distribution of the term.
The inter-class distribution of the term also has an effect on the classification capability. If a term t i appears almost in every category, the classification capability of t i will be weak. And likewise, if a term t i appears only in one category and the distribution in the category is homogeneous, t i will have a good ability to distinguish categories. Hence, the less homogeneous the inter-class distribution of the term is, the stronger the classification capability of the term will be. So, we will get Eq. (9) as the following.
Here, K is the number of categories in collection D, tf ki is the average frequency of term t i within the single category C k , and tf i is the average frequency of term t i in collection D. It's easy to see when the variance of set {tf 1i , . . . , tf ki , . . . , tf Ki } is large, the fluctuation will be large. This reflects that the inter-class distribution of t i is uneven and the classification capability of term t i is strong.
According to these two points, it's clear that the classification capability of the term is strong when the inter-class distribution of the term is uneven and the intra-class distribution of the term is homogeneous. Besides, term frequency of term t i also has an effect on the classification capability. It means the term which has a good ability to distinguish category should have a high term frequency in the category. So term frequency should be used to construct feature selection function. So we can get the following formula.
Finally we construct the following function to measure the classification capability of the term.
Here, = K ! (K −2)! * 2! , and K is the number of categories in collection D. Experiment results show that features selected by the proposed approach have stronger abilities to classify texts.

Algorithm description
According to above, we present a new feature selection algorithm, FSATD, based on the distributions of terms. Its pseudocode is as follows.

Experiments setup
The experiments are performed on a PC with operating system of Windows 7, an i3 CPU (2.40GHz) and an 8G memory. The programming environment is JDK 1.6.

Experimental data
In our experiments, we use the popular datasets-20NewsGroup and SougouCS. The 20NewsGroup corpus is a collection of about 20,000 newsgroup documents nearly evenly distributed among 20 discussion groups, and every group consists of 1000 documents. All letters are converted into lowercase, and the word stemming is applied. In addition, we use the stop words list to filter words.
The corpus SougouCS is from Sogou Laboratory. As the number of web pages in some classes is too small, we only choose 12 classes. And they are car, finance, IT,

Document representation
Documents are represented by Vector Space Model (Zhang 2010;Salton et al. 1975). That is, the content of a document is represented by a vector in the term space. It is illustrated in details as the following. V (d) = (t 1 , w 1 (d); . . . ; t i , w i (d); . . . ; t n , w n (d)), where n is the number of terms in a document d, and w i (d) is the weight of a term t i in document d. In experiments, TF-IDF (Term Frequency-Inverse DF) (Xiong et al. 2008;Salton and Buckley 1988) is used to calculate the weight.

Classifier selection
In the experiments, kNN classifier (Chen 2011) is used as the basic classifier. kNN is widely used in text classification as it is easy and has lower error rate in relative terms. The similarity measure used for the classifier is the cosine function.
In kNN, training data set and testing data set are required. So we randomly select 67% instances from each category as training data and the rest as testing data (Wang et al. 2014).

Performance measures
We measure the effectiveness of classifiers in terms of the combination of precision (p) and recall (r) which are widely used in text categorization. That is, we use the wellknown F 1 function (Sebastiani 2002) as follows.
For multi-class text categorization, F 1 is usually estimated in two ways. And they are the macro-averaged F 1 (macro-F 1 ) and the micro-averaged F 1 (micro-F 1 ). In this paper, we only use macro-F 1 , as shown in Eq. (13).
where F 1 (k) is the F 1 value of the predicted kth category.

Results and discussion
The kNN classifier is sensitive to the value of k. So we have a comparative study with the performance of FSATD, DF and t-Test on 20NewsGroup and SougouCS corpus with the different k values.
The classification results on 20NewsGroup and SougouCS corpus with the different k values are shown in Figs. 1 and 2. The results show that the macro-F 1 values of FSATD, DF and t-Test are different with different k values. But FSATD consistently outperforms DF and t-Test in the performance of macro-F 1 values no mater what value k is. So we set k = 20 in the follow-up experiments in view of the sizes of the two data sets and the classification performance. Figure 3 shows the precision and recall of DF, t-Test and FSATD on the 20NewsGroup corpus. And in our experiments, 1,500 features are selected for convenience in feature space. It is clear that FSATD achieves better performance than DF and t-Test, and the precision and recall of most categories have some improvements.
As shown, it is clear that FSATD achieves better performance than DF and t-Test ones. When the dimensionality of feature space is reduced, their differences show to be bigger among three algorithms.  Figure 5 depicts the precision and recall performance of DF, t-Test and FSATD on the SougouCS corpus when 4500 features are selected in original feature space. It is clear that FSATD achieves better performance than DF and t-Test in most categories. But for a few categories, FSATD does not get better precisions. Through analyzing, we find that some categories, such as fashion and entertainment, have many common words which make the boundaries between categories obscure and have a negative impact on precision. In these categories, the intra-class distributions of these words are uneven, and the number of documents which contain the common words is low. DF selects features according to the DF. The word can be reserved only when it appears in adequate documents. As the DF of the common words is low, DF is not easy to select them as their main features. During selecting features, t-Test mainly considers intra-class distributions of the words. However, the intra-class distributions of the common words are uneven, so t-Test also does not readily select them as main features. FSATD considers the interclass and the intra-class distributions of the words sufficiently. While these common words appear only in a few categories, so the value of the words calculated by FSATD is high. Therefore in these categories, FSATD is inclined to select the common words as features compared to DF and t-Test.
Through the above experiments, it is clear that FSATD achieves better performance than DF and t-Test. This is because term frequency, the inter-class and the intra-class distribution of the terms are all considered synthetically in FSATD. While DF only Fig. 4 Macro-F 1 performance on the 20NewsGroup corpus. In order to verify the performance of FSATD on the 20NewsGroup corpus, different dimensionalities are selected when the dimensionality of feature space varies. And finally we compare their values of macro-F 1 for three algorithms. And the details are shown considers DF and t-Test mainly considers intra-class distribution of the word. So FSATD can select more reasonable features which have a positive impact on the classification performance than DF and t-Test.

Conclusion
Feature selection plays an important role in text classification and has an immediate impact on text categorization. Most existing feature selection methods use DF. Through the analysis, we discover that term frequency has a great influence on feature selection. In view of this, we propose a feature selection approach based on term distributions in this paper. Additionally, term frequency is considered sufficiently. The experimental results on 20NewsGroup and SougouCS corpus show that FSATD achieves better performance than DF and t-Test.