Extracting Hierarchies from Data Clusters for Better Classiﬁcation

: In this paper we present the PHOCS-2 algorithm, which extracts a “Predicted Hierarchy Of ClassiﬁerS”. The extracted hierarchy helps us to enhance performance of ﬂat classiﬁcation. Nodes in the hierarchy contain classiﬁers. Each intermediate node corresponds to a set of classes and each leaf node corresponds to a single class. In the PHOCS-2 we make estimation for each node and achieve more precise computation of false positives, true positives and false negatives. Stopping criteria are based on the results of the ﬂat classiﬁcation. The proposed algorithm is validated against nine datasets.


Introduction
The notion of classification is very general.It can be used in many applications, for example, text mining, multimedia processing, medical or biological sciences, etc.The goal of text classification is to assign an electronic document to one or more categories based on its contents.
The traditional single-label classification is concerned with a set of documents associated with a single label (class) from a set of disjoint labels.For multi-label classification, the problem arises as each document can have more than one label [1,2].
In some classification problems, labels are associated with a hierarchical structure, in which case the task belongs to hierarchical classification.If each document may correspond to more than one node of the hierarchy, then we deal with multi-label hierarchical classification.In this case, we can use both hierarchical and flat classification algorithms.In hierarchical classification, a hierarchy of classifiers can be built using a hierarchy of labels.If labels do not have a hierarchical structure, we can extract a hierarchy of labels from a dataset.It can help us to enhance classification performance.
However, there are some general issues in the area of hierarchical classification: • In some cases classification performance cannot be enhanced using a hierarchy of labels.Some authors [3] showed that flat classification outperforms a hierarchical one in case of a large number of labels.So one should always compare a hierarchy with the flat case as a base line at each step of the hierarchy extraction.• A hierarchy is built using some assumptions and estimations.One needs to make more accurate estimations in order not to let performance decrease due to rough computations.In hierarchical classification, a small mistake made by the top level of classifiers greatly affects the performance of the whole classification.• Algorithms of extracting hierarchies require some external parameters.One needs to reach balance between the number of parameters and the effectiveness of an algorithm.Eventually, a smaller number of parameters leads to more simple usage.
In the previous work [4] we proposed and benchmarked the PHOCS algorithm that extracts a hierarchy of labels, and we showed that hierarchical classification could be better than a flat one.The main contribution of this work is enhancing the PHOCS algorithm.
We pursue the goal to increase performance of hierarchical classification using hierarchies built by the PHOCS algorithm.We want to reach this goal by solving the problems listed above.We make the estimation function more precise.We make estimation of false positives, true positives and false negatives and then calculate relative measures.We change stopping criteria as well.In the first version of the PHOCS, we used an external parameter that made the depth of our predicted hierarchy no more than five.We removed this parameter, and as stopping criteria, we now use a comparison of our estimated performance with the flat classification results.

State of the Art
In text classification, most of the studies deal with flat classification, when it is assumed that there are no relationships between the categories.There are two basic hierarchical classification methods, namely, the big-bang approach and the top-down level-based approach [5].
In the big-bang approach, a document is assigned to a class in one single step, whereas in the top-down level-based approach, classification is performed with the classifiers built at each level of a hierarchy.
In the top-down level-based approach, a classification problem is decomposed into a set of smaller problems corresponding to hierarchical splits in a tree.First, classes are distinguished at the top level, and then the lower level distinctions are determined only within the subclasses at the appropriate top-level class.Each of these sub-problems can be solved much more accurately as well [6,7].Moreover, a greater accuracy is achievable because classifiers can identify and ignore commonalities between the subtopics of a specific class, and concentrate on those features that distinguish them [8].This approach is used by most hierarchical classification methods due to its simplicity [5,6,[9][10][11].They utilize the known hierarchical (taxonomy) structure built by experts.
One of the obvious problems with the top-down approach is that misclassification at a higher level of a hierarchy may force a document to be wrongly routed before it gets classified at a lower level.Another problem is that sometimes there is no predefined hierarchy and one has first to build it.It is usually built from data or from data labels.We address the latter problem, which seems to us not that computationally complex, since the number of labels is usually less than the number of data attributes.
In our research, we follow the top-down level based approach utilizing a hierarchical topic structure to break down the problem of classification into a sequence of simpler problems.
There are approaches implying linear discriminant projection of categories to create hierarchies based on their similarities: [12,13].They show that classification performance gets better as compared with a flat case.There is a range of methods aimed to reduce the complexity of training flat classifiers.Usually they partition data into two parts and create a two-level hierarchy, e.g., [14].
The HOMER method [15] constructs a Hierarchy Of Multi-label classifiERs, each one dealing with a much smaller set of labels with respect to |L| and with a more balanced example distribution.This leads to an improved estimated performance along with linear training and logarithmic testing complexities with respect to |L|.At the first step, the HOMER automatically organizes labels into a tree-shaped hierarchy.This is accomplished by recursively partitioning a set of labels into a number of nodes using the balance clustering algorithm.Then it builds one multi-label classifier at each node apart from the leaves.
In the PHOCS, we use the same concept of hierarchy and meta-labels.Tsoumakas et al. [16] also introduce the RAkEL classifier (RAndom k labELsets, k is a parameter specifying the size of labelsets) that outperforms some well-known multi-label classifiers.
In the recent work [17], the authors used datasets with predefined hierarchies and tried to guess them, but did not construct a hierarchy that could be good for classification.Generally, this is a more challenging task than a standard hierarchical multi-label classification, when classifiers are based on a known class hierarchy.In our research, we pursue a similar objective.
In 2011 the second Pascal challenge on large-scale classification was held.Wang et al. [3] got the first place in two of the three benchmarks.They enhanced the flat kNN method and outperformed hierarchical classification.They used an interesting method of building a hierarchy as well, which employs only existing labels without the use of any meta-labels.The performance was lower than in the flat case.There are two specific issues when building a taxonomy in a such way.For example, Reuters-21578 already has meta-labels that generalize other labels.They are not used in the classification.Some datasets do not have such meta-labels or any structure of labels.Another issue is that two very similar labels, associated with two contiguous categories, should be on one layer.However, in such way of building hierarchy the may be put in a parent-child relation.To solve the mentioned issues, we will build a hierarchy using meta-labels.

General Concept
The main idea is transformation of a multi-label classification task with a large set of labels L into a tree-shaped hierarchy of simpler multi-label classification tasks, each one dealing with a small number k of labels: k << |L| (sometimes k < |L|).Below follows the explanation of the general concept of the multi-label hierarchical classification [4].
Each node n of this tree contains a set of labels L n ⊆ L. Figure 1 shows 6 leaves and 3 internal nodes.There are |L| leaves, each containing a singleton (a single element set) {λ j } with a different label j of L. Each internal node n contains a union of labelsets of its children: The root accommodates all the labels: L root = L.
Meta-label µ n of node n is defined as conjunction of the labels associated with that node: µ n = ∪λ j , λ j ∈ L n .Meta-labels have the following semantics: a document is considered annotated with the meta-label µ n if it is annotated with at least one of the labels in L n .Each internal node n of a hierarchy also accommodates a multi-label classifier h n .The task of h n is to predict one or more meta-labels of its children.Therefore, the set of labels for Figure 1 shows a sample hierarchy produced for a multi-label classification task with 6 labels.For multi-label classification of a new document, the classifier starts with h root and then forwards it to the multi-label classifier h c of the child node c only if µ c is among the predictions of h parent(c) .The main issue in building hierarchies is how to distribute the labels of L n among the k children.One can distribute k subsets in such a way that the labels belonging to the same subset remain similar.In [15], the number k of labels is a set given for each L n .

Building One Layer: Example
In this work, we solve the problem of distribution of labels L n among children nodes by choosing the best value of k at each node according to the estimation of the hierarchy performance.We use the divide-and-conquer paradigm for our algorithm design [15].Our algorithm starts from the whole set of labels and its goal is to build a hierarchy of labels optimizing classification performance.In each step, we divide the current set of labels into groups that correspond to the child nodes of that set.Our algorithm is recursive and proceeds until the current set contains only one label.Such sets will be leaves of the hierarchy.
Illustration of one step of our algorithm can be found in Figure 2. It will proceed in the following way.

Algorithm For Building Hierarchies
Our algorithm is recursive (Algorithm 1).It takes a training dataset as an input, and the minimum and maximum numbers of clusters k min and k max .It starts from the whole set of labels, makes K-means clustering of them for a different number of clusters from k min to k max (line 4).We cluster labels using documents as binary features for clustering.If a label is associated with a document, then a corresponding feature value is 1, otherwise 0. Feature space size equals N, where N is the number of documents.We compose meta-labels from clusters for each partition (line 5) and measure their efficiency using a classification task (line 6).
All sets of clusters are candidates for the next layer of the hierarchy.We choose the best partition with the help of an estimation algorithm (line 8).Using the best-estimated partition, we build meta-labels (each meta-label consists of classes from one cluster, line 10).After that, we make this process recursive for the child meta-labels.

Algorithm Complexity
The prediction function has the complexity O(k max • |L|) for each cluster.For all the clusters it is O(k 3 max • |L|) (line 8 in Algorithm 1).So the running time in the root node can be defined as the sum of these quantities: Algorithm 1 The PHOCS algorithm for hierarchy building 1: function HIERARCHY(T rainSet, Labels, RootN ode, Kmin, Kmax) P min ← P erf ormanceM easure(T rainSet) 3: for i ← Kmin, Kmax do 4: C[i] ← doClustering(T rainSet, Labels, i) DataSet ← dataM etaLabeling(T rainSet, C) Results[i] ← P erf ormanceM easure(DataSet) T rainP art, T estP art ← split(DataSet) Let us consider the computational complexity of building one layer.Suppose each node at this level has N documents, although they are fewer.Since each label of L lies in a single cluster, the total complexity of all clusterings on the layer is Similarly, the complexity of the prediction function for all clusters in all nodes will not exceed O(k 3 max • |L|).Denote the mean number of labels in the document as A, whereas in fact, the number of documents in all nodes at the same level does not exceed N • A. If the classifier learning algorithm has linear complexity with respect to the number of documents, the complexity of building all classifiers will not exceed So the running time of building a layer can be defined as the sum of these quantities: , where f (M, N, L) is complexity of building a multi-label classifier in binary transformation case.
We showed the complexity of building one layer.The number of layers in a good hierarchy does not exceed 5.In our paper we used the decision tree algorithm C4.5 [18].For C4.5 f (M, N ) = M • N • log(N ).

General Idea
The goal of the performance estimation function is to estimate classification performance of each partition.With our estimation function, we want to determine which partition is better.We employ a training set for this function.At the same time we need a test set in order to decide which partition is better.We use a part of the training set for this, and the other part remains for training purposes.
We build a classifier for each partition.Each cluster represents one class.We classify the documents and get the performance measure that shows how good a particular partition is.Various measures can be used in our algorithm.The goal of our algorithm is to build a hierarchy with an optimum performance measure.For example, for partition into 2 clusters we get the classification performance measure 0.97 (Figure 5).For partition into 3 clusters the measure is 0.93 and for partition into 4 clusters it is 0.88.We believe that on further layers of the hierarchy, the partition into k clusters will be the same as in the performance table (Figure 5).We also know various features of clusters, such as size, diversity, etc.Therefore, it is possible to explore all possible partitions as well as final hierarchies and to estimate their performance.For example, one may want to make estimation for partition into 3 clusters (Figure 3).
Cluster {l 1 } has only one class and we assume that its performance is 1.Cluster {l 2 , l 3 } has 2 classes and its performance is believed to be similar to the performance from the table, which is 0.97.Cluster {l 4 , l 5 , l 6 } can be clustered further in 2 different ways (Figure 4).We calculate the number of labels at different levels for the sake of simplicity.So we do not distinguish which labels are in the cluster of size 2: {l 4 , l 5 }, {l 4 , l 6 } or {l 5 , l 6 }.Finally, we have only two different partitions (Figure 4).
We make performance estimation for the first partition based on the table from Figure 5.It is 0.93.The performance of the second partition cannot be estimated using the referenced table since it contains a sub-hierarchy.We propose a certain approach for doing this.

Approach
In the previous version of our algorithm (we will refer to it as to PHOCS-1) we made estimation in the following way.We used F 1-measure as a performance measure and assumed that the F 1-measure becomes smaller layer by layer (as the hierarchy is growing), that is, the F 1-measure on layer k is larger than on layer k +1.We estimated it at k +1 level as F 1 * k+1 = k i=1 F 1 i , where i is the layer number.This estimation is rather rough and it is possible to make it finer.We propose to use absolute values of errors and the structure of nodes as well as more information about clusters-their size and performance values.We will denote: • C -cluster size; • N C -the number of documents in the cluster; • K -the number of child clusters; • A C -the average number of labels for documents in the cluster; • S -the number of possible further partitions for the cluster; • * index is used for estimated numbers and measures; • * max index is used for the best estimation for the cluster (among all possible partitions of this cluster); • * result index is used for estimation of the whole partition (split); • q index denotes the number of partitions for a particular cluster; • T index is used for the values of the performance measure in the table that we fill in (like in Figure 5).Each record in the table corresponds to a specific number of child clusters K.
Our goal is to estimate the absolute values of true positives (T P * ), false negatives (F N * ) and false positives (F P * ).Then we have to calculate relative performance measures that can be used for optimizing the hierarchy, such as F 1-measure (F 1 * ), Precision (P * ) or Recall (R * ).The example of estimation process is represented in Figure 6.Assume that we are currently on layer N .On this layer we have already made clustering (Figure 2, step 2) and filled in the performance table (Figure 5).Assume, we are estimating classification performance for one of the partitions {l 4 , l 5 , l 6 } (Figure 3 k = 3 and Figure 6) with two ways of splitting (Figure 4, S = {1, 2}).T P * , F N * , and F P * are computed in the following way: • T P * .The number of true positives will decrease with each next level of the hierarchy.T P * will depend on R and we will approximate it with the following function: T P * N +2 = T P • R T K .K equals 3 for T P 1 * N +2 and 2 for T P 2 * N +2 (Figure 6, layer N + 2).• F N * .We know The main problem is to estimate F P .Indeed the result of F P * N +1 should be between T P • (1 − P T K ) and F P + T P • (1 − P T K ).We use a rather pessimistic estimation of it: We computed T P * , F P * , T N * on different layers of our cluster.We believe that a hierarchy should be rather balanced with leaves on the last two layers only.Let us denote the last layer as M .Then there are two groups of leaves: leaves on the last layer (N L M ) and leaves on the previous layer (N L M −1 ).6 represents a cluster of size 3.All leaves are on layer N + 2 for the first split.One leaf is on layer N + 2 and two leaves are on layer N + 3 for the second split.
Then we are able to compute relative measures for our cluster: P q * = T P q * T P q * +F P q * R q * = T P q * T P q * +F N q * F 1 q * = 2•P q * •R q * P q * +R q * Therefore, we are able to find the best further partitioning of the cluster.If we maximize F 1, then the best partitioning of the cluster will be partitioning with the maximal F 1. We will use * max with absolute estimations for the best estimated partitioning of our cluster.F 1 * max = max i∈S F 1 i * .We take into account the size of clusters in order to compute estimation for the whole partition (split).The more documents there are in a cluster the higher influence they have on the estimation.Estimation is made for each cluster separately.First, we find the best further partitioning of the cluster.Second, we summarize the absolute numbers: Now we are able to compute the relative measures P * result ,R * result , and F 1 * result .The general idea is to minimize the number of external parameters in our algorithm.k min should always equal 2, and k max is the only external parameter and it should not be greater than the square root of |L|.We have changed the stopping criteria of our algorithm.We make comparison with the flat classification result as stopping criteria.If our prediction is worse than the flat case, then we stop further building of the hierarchy (in the previous version we stopped building a hierarchy after several layers).

Performance Estimation Function
Let us summarize the proposed approach for performance estimation in a sequence of steps.We had completed the following steps before the call of the performance estimation function: 1.A certain number of labels is given.2. The labels are clustered.As a result, we have different partitions.3. Classification is done using the clusters for different partitions.4. A table with the performance measures of classification for all clusters is filled in (P T , R T and F 1 T ).T P , F P , F N for all clusters are saved.
The input for the performance estimation function is the following: • Partitions configuration (the number of different partitions, their sizes).
• Clusters configuration (T P , F P , F N as the result of classification, C, N C , A C ).
• A table with the measures (P T , R T and F 1 T ).
Finally, we are able to list all steps of the performance estimation function (denoted as function PERFESTIMATE in the Algorithm 1): 1.For each possible further partitioning of each cluster in each partition: The estimation function returns the best partition and the estimated performance for it.

Experiments
All the experiments are performed on multi-label datasets available at [19].Table 1 exhibits basic statistics, such as the number of examples and labels, along with the statistics that are relevant to the label sets [16].
Multi-Label classification problem can be solved in different ways [2].Problem transformation methods allow converting a multi-label problem to a single-label one.Below is the list of the most frequently used approaches: • Binary Relevance.One builds a classifier for each label, which will make a decision about this label.• Label Power-set transformation.One builds a multiclass classifier, where each class corresponds to a set of labels associated with a document.• One vs. one.One trains a classifier for each pair of labels.The decision is made by voting.We use Binary Relevance transformation because of the nature of the data (Table 1).The last column shows the number of classes in case of Label Power-set transformation.This transformation can work on Scene, Genbase and Medical.In other datasets, the number of classes will be rather large so the number of training examples for each class will be low and classification performance will be poor as well.
It is also rather hard to build one versus one flat classifier.There will be 100, 000 classifiers for Corel5k.It is much easier to use it in a hierarchy, and we plan to do it in our future work.
Each dataset is divided into the training and test parts in the proportion 2 to 1, respectively.There are no any other transformations of the datasets.In particular, there is no attribute selection.The first four datasets are used in all experiments and the last five are used only with the PHOCS-2.
The decision tree algorithm C4.5 [18] is chosen as the basic multi-label classifier.The K-means algorithm is used for clustering and building hierarchies.The micro and macro measures of classification accuracy (precision (P), recall (R) and F 1-measure) are used [20].
The parameter values for the PHOCS are chosen as k min = 2 and k max = 10.Such k max is chosen since the number of labels in our experiments has the order of 100, so the hierarchy contains at least 2 layers.
The experiment results are represented in Table 2.
We removed the external parameter, so the PHOCS-2 has only two parameters: k min , which should always equal 2, and k max , which can be the only external parameter in the ideal case.We got a better F 1-measure in comparison with the results from [4] for all four datasets that we used there.In all cases the current version of the algorithm demonstrated the best performance (F 1-measure).
The experimental study of the PHOCS-2 performance on nine multi-label datasets justifies its effectiveness.We got significantly better results in five of them compared with the flat case.It was difficult to improve the result of the Genbase, because its performance is already 0.97, and we have not improved the performance in the Mediamill and the Yeast.HOMER [15] was tested only on two datasets.One of them is Mediamill and we can compare results.There is no baseline in [15].PHOCSv2 outperforms HOMER by 10% in F 1-measure on Mediamill dataset.In most cases, our algorithm provides better F1 due to better Recall.We are able to optimize other measures as well.It is useful when one has specific requirements to a classifiers performance.

Results and Conclusion
We proposed several enhancements for the PHOCS algorithm that builds hierarchies from flat clusterings in order to enhance classification accuracy.To build a better hierarchy we used absolute values of errors, employed the number and structure of nodes, cluster sizes and individual performance values for each cluster.We changed the stopping criteria as well to compare our hierarchy with a flat one.
The experimental study shows effectiveness of the enhancements.We have removed one of the parameters as well.As a result, it has become easier to use the PHOCS.
Our future work will be related to improving the performance estimation function and adding a possibility to return to a previous layer in case of false prediction.We would like to use or create a classifier that can take advantage of a hierarchy.Another goal is to compare our algorithm with EkNN [3] that has won the second Pascal challenge.

Figure 4 .
Figure 4. Different ways of splitting the labels.

Let k min equals 2 .
Denote N as the number of documents.Denote M as the number of attributes.Denote |L| as the number of labels.Consider the computational complexity of the first step of the algorithm.Each clustering has complexity O(M • N • |L|) (line 4 in Algorithm 1).We will also train O(k max ) binary classifiers for one clustering (line 6 in Algorithm 1), the complexity of training one classifier is O(f (M, N )).So the complexity of cycle (lines 3-7 in Algorithm 1) has complexity O

Figure 5 .
Figure 5. Example: filling in the table.

2 ., 4 .
(a) count the number of leaves on different layers of the predicted taxonomy (nL N +i , nL N +i−1 ) (b) estimate the number of positives and negatives T P * cluster , F P * cluster , F N * cluster .(c) estimate relative measures P * cluster , R * cluster , F 1 * cluster .For each cluster, estimate the best further partitioning (F 1 * max = max i∈S F 1 i * ). 3. For each partition (for each k), estimate the absolute and relative parameters on the current layer: T P * result k Choose the best partition based on max k min ≤k≤kmax F 1 * result k .

Table 1 .
Multi-Label Datasets and Their Statistics.