Computational Intelligence and Neuroscience
Volume 2017 (2017), Article ID 8986360, 11 pages
https://doi.org/10.1155/2017/8986360

Research Article

Clustering Categorical Data Using Community Detection Techniques

Huu Hiep Nguyen

Institute of Research and Development, Duy Tan University, P809 7/25 Quang Trung, Danang 550000, Vietnam

Correspondence should be addressed to Huu Hiep Nguyen; nguyenhuuhiep2@dtu.edu.vn

Received 30 August 2017; Revised 8 November 2017; Accepted 16 November 2017; Published 21 December 2017

Academic Editor: Elio Masciari

Copyright © 2017 Huu Hiep Nguyen. This is an open access article distributed under the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.

Abstract.

With the advent of the -modes algorithm, the toolbox for clustering categorical data has an efficient tool that scales linearly in the number of data items. However, random initialization of cluster centers in -modes makes it hard to reach a good clustering without resorting to many trials. Recently proposed methods for better initialization are deterministic and reduce the clustering cost considerably. A variety of initialization methods differ in how the heuristics chooses the set of initial centers. In this paper, we address the clustering problem for categorical data from the perspective of community detection. Instead of initializing modes and running several iterations, our scheme, CD-Clustering, builds an unweighted graph and detects highly cohesive groups of nodes using a fast community detection technique. The top- detected communities by size will define the modes. Evaluation on ten real categorical datasets shows that our method outperforms the existing initialization methods for -modes in terms of accuracy, precision, and recall in most of the cases.

1. Introduction

Clustering task is a form of unsupervised learning that aims at finding underlying structures in unlabeled data. Objects are partitioned into homogeneous groups or clusters so that intracluster items have high similarity but are very dissimilar to objects in other clusters. A lot of clustering methods have been proposed and developed over decades (for a recent survey, see [1]). Hierarchical clustering and partitional clustering are two main types of clustering algorithms. While hierarchical clustering produces a hierarchy of partitions (i.e., a dendrogram) over the dataset by applying agglomerative or divisive strategies, partitional clustering usually assumes a fixed number of clusters and tries to maximize the homogeneity within the clusters.

For numerical data, the -means algorithm is a well-known and widely used method in practice due to its simplicity and efficiency. -means finds a set of cluster centers for a dataset such that the sum of squared distances of each point to its nearest cluster center is minimized. Lloyd’s algorithm [2] begins with arbitrary centers, typically chosen uniformly at random from the data points. Each point is then assigned to the nearest center, and each center is recomputed as the center of mass of all points assigned to it. These two steps are repeated until the process stabilizes. To remove the numeric-only limitation of the -means algorithm, Huang [3] developed the -modes algorithm which extends the -means algorithm by using (1) a simple matching dissimilarity measure for categorical attributes (2) modes in place of means for clustering and (3) a frequency-related strategy to update modes to minimize the clustering cost. The algorithm is shown to achieve convergence with linear time complexity with respect to the number of data items.

However, the -modes algorithm is also very sensitive to the choice of initial cluster centers and an improper choice may result in highly undesirable cluster structures. The same phenomenon happened in -means which led to the better seeding solutions such as k-means++ [4] and its derivatives -means [5] and - [6]. To better initialize cluster centers in -modes, a lot of methods have been developed [7–10]. The common point of [7, 8, 10] is to use the density of each data point together with the distance to determine sequentially the initial cluster centers. Khan and Ahmad [9] proposed to use multiple clustering of the data based on attribute values in different attributes.

In this paper, we develop a new clustering method for categorical data based on community detection techniques [11]. Considering each data point as a node, we build a simple graph in which an edge connects any two nodes if the Hamming distance between them is less than a threshold. The threshold is simply estimated via the number of data points , the number of clusters , and the pairwise Hamming distance distribution. Given the graph , we run the Louvain algorithm [12] to detect nonoverlapping cohesive communities within . The top- communities by size will be retained as the core clusters, each of which is represented by a mode. The remaining data points (if any) are assigned to the nearest mode. Note that our algorithm is not an initialization technique as [3, 7–10] because it produces clusters directly.

Compared to prior work, our scheme highlights the following features:

(i)We propose a novel clustering method called CD-Clustering for categorical data using community detection techniques. Our scheme uses a simple heuristic to determine the distance threshold for graph construction. It is also deterministic as opposed to the traditional -modes with random initialization of cluster centers.(ii)We evaluate our scheme on ten real categorical datasets and compare it against random initialization and two other initialization methods. The results show that our technique performs better than the competitors in terms of accuracy for most of the cases.

The remainder of the paper is organized as follows. Section 2 briefly reviews related work in -modes clustering and community detection. Section 3 discusses several key concepts used in this paper via some illustrative examples. In Section 4, we describe a simple estimation of the distance threshold and our main algorithm. The evaluation and comparison are shown in Section 5. Finally, Section 6 concludes the paper with pointers to future work.

2. Related Work

2.1. -Modes and Initialization Techniques

As in -means, the random initialization method has been widely used in -modes clustering for its simplicity. However, the random method does not guarantee a unique clustering result, and very poor clustering results may occur. To obtain desirable clustering results with low distortion, the -modes algorithm must be executed many times.

In [3], Huang proposed two simple initialization methods for -modes, in which the first method selects the first objects from the dataset as initial cluster centers, and the second method assigns the most frequent categories equally to the initial cluster centers. However, the first method works only if the first objects come from disjoint clusters while the second method lacks a uniform criterion for selecting initial clusters.

Wu et al. [10] proposed a density based initialization method for -modes. Cao et al. [8] presented a method to select initial cluster centers by considering the distance between objects and the density of each object. Bai et al. [7] proposed an initialization method that is similar to [8] but tries to avoid selecting the boundary objects among clusters as the first cluster center. However, the evaluation of results in [7] has some problems: for several datasets, the accuracy, precision and recall values are computed incorrectly as reported by Khan and Ahmad [9]. In [9], Khan and Ahmad presented an initialization algorithm for -modes by performing multiple clustering of data based on the attribute values present in different attributes.

A long with the heuristics for cluster initialization discussed above, there are many ideas on improving the dissimilarity scores for the standard -modes algorithm [13–16]. Ng et al. [15] gave a rigorous proof that the object cluster membership assignment method and the mode updating formula under the dissimilarity measure proposed in [14] indeed minimize the objective function. Cao et al. [13] proposed a new dissimilarity measure to take into account of the distribution of attribute values on the whole universe. In [16], Zhou et al. took a step further by defining the Global-Relationship dissimilarity (GRD) measure.

2.2. Community Detection in Graphs

There is a vast literature on community detection in graphs. For a recent comprehensive survey, we refer to [11]. In this section, we discuss several classes of techniques.

Newman and Girvan [17] propose modularity as a quality of network clustering. It is based on the idea that a random graph is not expected to have a modular structure, so the possible existence of clusters is revealed by the comparison between the actual density of edges in a subgraph and the density one would expect to have in the subgraph if the nodes of the graph were connected randomly (the null model).

Many methods for optimizing the modularity have been proposed over the last ten years, such as agglomerative greedy [18], simulated annealing [19], spectral optimization [20], and Louvain method [12], just to name a few. Other methods include random walks [21], statistical mechanics [22], label propagation [23], and InfoMap [24]. The recent multilevel approach, also called Louvain method, by Blondel et al. [12] is among top performance schemes. It scales very well to graphs with hundreds of millions of nodes/edges.

3. Preliminaries

In this section, we review several key concepts in the -modes algorithm and community detection techniques. We also discuss how the clustering problem of categorical data can be solved from the perspective of community detection.

Notations summarizes the notation used in this paper.

3.1. Clustering Categorical Data

Let be a categorical dataset with data points . Each data point has categorical attributes from the set . In other words, the dataset can be represented by a table with rows and columns in which indicates the th attribute of the data point .

The -modes clustering algorithm [3] is an extension of the -means algorithm for clustering categorical data by using a simple dissimilarity measure. It also adopts a frequency-related strategy to update modes in the clustering to minimize the clustering costs. The simplest matching dissimilarity measure between two data points and is defined by Hamming distance:

where denotes the th attribute of and if or otherwise. Obviously, the Hamming distance between any two data points lies in the set .

Given a set of data points , a mode of is an object where that minimizes the sum . In other words, is the most frequent value in with respect to the th attribute [3]. Note that is not necessarily an object of . When a mode is not an object of a set, it can be assumed as a virtual object.

The original -modes algorithm [3] tries to minimize the following cost function:

where and . The -modes algorithm [3] runs the following steps:

(1)Select initial modes, one for each cluster.(2)Allocate an object to the cluster whose mode is the nearest to it. Update the mode of the cluster after each allocation using the most frequent attribute values.(3)After all objects have been allocated to clusters, retest the dissimilarity of objects against the current modes. If an object is found such that its nearest mode belongs to another cluster rather than its current one, reallocate the object to that cluster, and update the modes of both clusters.(4)Repeat (3) until no object has changed clusters after a full cycle test of the whole dataset.

3.2. Community Detection via Modularity Optimization

Given a simple graph with disjoint communities, the modularity is defined as

where is the number of clusters, is the total number of edges joining nodes in community , and is the sum of the degrees of the nodes of . Modularity is a scalar value in the range with larger values implying better clustering.

Example 1. Using Figure 1, we illustrate how to compute the modularity of a graph with respect to a clustering . The graph has six nodes and seven edges (). In Figure 1(a), the clustering is , so (two clusters). For the first cluster, . For the second cluster, . Hence, following formula (3), the modularity is .
Similarly, for the clustering on Figure 1(b)   , the modularity is . Clearly, the modularity of is higher than that of . This fact is also confirmed by looking at the two types of clustering in which partitions the nodes into more homogeneous groups.

(a)

(b)

Figure 1: Modularity of two different clustering.

Since its introduction in 2008, Louvain method [12] becomes one of the most cited methods for the community detection task. It optimizes the modularity by a bottom-up folding process. The algorithm is divided into passes, each of which is composed of two phases that are repeated iteratively. Initially, each node is assigned to a different community. So, there will be as many communities as there are nodes in the first phase. Then, for each node , the method considers the gain of modularity if we move from its community to the community of a neighbor (a local change). The node is then placed in the community for which this gain is maximum and positive (if any); otherwise it stays in its original community. This process is applied repeatedly and sequentially for all nodes until no further improvement can be achieved and the first pass is then complete.

Example 2. We demonstrate Louvain method in Figure 2 with a graph of 13 nodes and 20 edges. If each node forms its own singleton community, the modularity will be . In the first pass of Louvain method, each node moves to the best community selected from its neighbors’ communities. We get the partition with modularity 0.46375. The second phase of first pass builds a weighted graph corresponding to the partition by aggregating communities. The second pass repeats the folding process on this weighted graph to reach the final partition with modularity 0.47.

Figure 2: Louvain method for modularity optimization.

This greedy agglomerative algorithm has several advantages as stated in [12]. First, its steps are intuitive and easy to implement, and the outcome is unsupervised. Second, the algorithm is extremely fast, that is, computer simulations on large modular networks suggest that its complexity is linear on typical and sparse data. This is due to the fact that the possible gains in modularity are easy to compute and the number of communities decreases drastically after just a few passes so that most of the running time is concentrated on the first iterations. Third, the multilevel nature of the method produces a hierarchical structure of communities which allows multiresolution analysis, that is, the user can zoom in the graph to observe its structure with the desired resolution.

Note that in Louvain method, the move of nodes to gain better modularity is restricted to neighbor (connected) communities. Therefore, detected communities belong to one and only one connected component. In other words, a community never spans different connected components of a graph.

4. Algorithm

4.1. Estimation of Hamming Distance Threshold

To build the graph for the dataset , we need to estimate the distance threshold so that any two data points and are connected if the Hamming distance . As mentioned in Section 3.1, the Hamming distance lies in the set . At one extreme , the graph has least edges which exist between duplicate data points only. At the other extreme , we get a complete graph : any two nodes are connected. Obviously, some values of the distance threshold will make look more modular than the others; that is, its nodes are well clustered in communities and therefore easier to detect.

In this paper, we propose a simple heuristic to estimate based on the distribution of Hamming distances between data points in given the number of clusters . With data points, there are pairwise distances. Trivially assuming that clusters are of equal size, each cluster will have points and the number of intracluster distances in each cluster is . In total, there are intracluster distances. In practice , so the ratio of intracluster distances over the number of pairwise distances is

In other words, given the cumulative distribution function (CDF) of pairwise distances, we can estimate at the point that and . Figure 3 illustrates this idea for the ten datasets used in our experiments.

(a) Soybean ()

(b) Mushroom ()

(c) Zoo ()

(d) Lung-Cancer ()

(e) Breast-Cancer ()

(f) Dermatology ()

(g) Vote ()

(h) Nursery ()

(i) Chess ()

(j) Heart ()

Figure 3: Estimation of the distance threshold . The horizontal line in each figure represents 1/.

We also observe that the expected Hamming distance between two random data points is large when the attribute values are assumed to be uniformly distributed. Specifically, given the set of attributes , the expected Hamming distance between two random data points and is

where is the cardinality of the th nonsingleton attribute. The larger , the larger the expected Hamming distance.

4.2. Clustering Algorithm

Now we describe our community detection-based clustering scheme (named CD-Clustering) which is outlined in Algorithm 1. The scheme consists of two phases. In the first phase, we compute all pairwise Hamming distances and the CDF of distance distribution (Lines (1)-(2)). Then, we estimate the distance threshold using a simple assumption in Section 4.1 (Lines (4)–(6)). In the second phase, we build the graph in which each node represents a data point. Two nodes are connected by an edge if their Hamming distance is not larger than (Lines (8)–(11)). In Line (12), we run the Louvain method [12] on to detect highly cohesive groups of nodes. The top-   detected communities by size will be retained (Line (13)). Then, we determine the mode for data points in each community (Lines (14)-(15)). The remaining data points (i.e., data points that do not belong to any of the top- communities) are assigned to the nearest mode (Lines (16)-(17)). As we show later in Section 5, except the dataset Mushroom, the number of remaining data points is very small.

Input: dataset with data points, each data point has

attributes. The number of clusters .

Output: clusters of data points .

compute pairwise Hamming distances

compute CDF for pairwise Hamming distances

// estimate distance threshold

for     do

(5) if   and   then

(6)break

(7) // clustering

(8)

(9)for     do

(10) if     then

(11)

(12) run Louvain method [12] on

(13) keep top- communities by size

(14)for each cluster   do

(15) compute the mode of

(16)for each remaining data point   do

(17) assign to the nearest mode ,

(18)return  

Algorithm 1: CD-Clustering.

The complexity of CD-Clustering is dominated by the computation of all pairwise Hamming distances and the Louvain method. All pairwise Hamming distances are computed in . The Louvain method runs empirically in the time linear to the number of edges [12]. Again, using the simple assumption that all clusters are of equal size, the number of intracluster distances is approximated as . So the number of edges in is also , making the runtime of Louvain method is . In total, the complexity of CD-Clustering is . The quadratic complexity is a main drawback of our CD-Clustering scheme which restricts its application to datasets of 50,000 data points or less. A similar scalability limitation appears in [25] in which the authors need a similarity matrix of size . An approximation of Hamming distance distribution is possible by considering, for example, the distances from any point to (instead of all ) other points. The complexity in this approximation scheme will be reduced to . We leave this idea for future work. Table 1 compares the time complexity of our CD-Clustering scheme with the two initialization methods [8, 9].

Table 1: Comparison of time complexity.

Clustering method
Time complexity

Cao et al. [8]

Khan and Ahmad [9]

CD-Clustering

5. Evaluation

In this section, we evaluate the performance of the proposed scheme. The real-world datasets and evaluation metrics are described in Sections 5.1 and 5.2. We show the performance of our method in Section 5.3. The clustering algorithm is implemented in C++ and run on a desktop PC with Intel® Core i7-6700@ 3.4 Ghz, 16 GB memory. For the sake of reproducibility, we provide our source code with the data (https://gitlab.com/hiepnh.duytan/Research/tree/master/k-modes-community).

5.1. Datasets

We pick ten purely categorical datasets from the UCI Machine Learning Repository [26] with a short description for each dataset as follows. Compared to the datasets used in [9], we add three new datasets: Nursery, Chess, and Heart. Note that we consider missing attribute values “?” as a new attribute value.

Soybean Small. This dataset consists of 47 cases of soybean disease each characterized by 35 multivalued categorical variables. These cases are drawn from four populations, each one of them representing one of the following soybean diseases: D1-Diaporthe stem canker, D2-Charcoat rot, D3-Rhizoctonia root rot, and D4-Phytophthorat rot. We keep only 21 nonsingleton attributes.

Mushroom Data. Mushroom dataset consists of 8,124 data objects described by 22 categorical attributes distributed over 2 classes. The two classes are edible (4208 objects) and poisonous (3916 objects). It has missing values in attribute 11.

Zoo Data. It has 101 instances described by 16 attributes and distributed into 7 categories. The first attribute contains a unique animal name for each instance and is removed because it is noninformative. All other characteristics attributes are Boolean except for the character attribute which corresponds to the number of legs that lies in the set .

Lung-Cancer Data. This dataset contains 32 instances described by 56 attributes distributed over 3 classes with missing values in attributes 5 and 39.

Breast-Cancer Data. This data has 699 instances with 9 attributes. Each data object is labeled as benign (458 or 65.5%) or malignant (241 or 34.5%). There are 9 instances in attributes 6 and 9 that contain missing attribute values.

Dermatology Data. This dataset contains six types of skin diseases for 366 patients that are evaluated using 34 clinical attributes, 33 of them are categorical and one is numerical. The categorical attribute values signify degrees in terms of whether the feature is present and contain largest possible amount or relative intermediate values. In our experiment, we discretize the numerical attribute (representing the age of the patient) into 10 categories.

Congressional Vote Data. This dataset includes votes for each of the US House of Representatives Congressmen on the 16 key votes. Each of the votes can either be a yes, no, or an unknown disposition. The data has 2 classes with 267 democrats and 168 republicans instances.

Nursery. This dataset was derived from a hierarchical decision model originally developed to rank applications for nursery schools. It contains 12,960 instances with 8 input attributes distributed over 5 classes.

Chess. This dataset contains 3,196 instances, each of which is a board-description for the chess endgame with 36 features. Each game is labeled one of the two classes: “win” and “nowin.”

Heart Disease. This dataset is the Cleveland heart disease database of 303 patients. The class represents presence of heart disease in the patient from 0 to 4. There are 13 attributes used in the experiments. We convert 5 numeric attributes (1st, 4th, 5th, 8th, and 10th) to categorical ones using the intervals of 10, 20, 60, 30, and 0.7, respectively. The 12th and 13th attributes contain missing attribute values.

Table 2 lists the characteristics of the chosen datasets. The columns avg.intra.dist and avg.inter.dist show the average intracluster and intercluster distances for each dataset, respectively.

Table 2: Dataset properties.

Dataset

avg.intra.dist
avg.inter.dist
AC

#comp
top-
Runtime (ms)

Soybean
47
21
4
7
5.54
12.48
1.0000
246
3
47
31

Mushroom
8,124
22
2
11
10.11
12.68
0.7244
12,924,407
1
5,366
8,284

Zoo
101
16
7
2
2.40
7.75
0.8218
701
7
100
109

Lung-Cancer
32
56
3
22
24.20
26.09
0.5938
160
4
29
110

Breast-Cancer
699
9
2
6
4.27
7.84
0.9514
115,068
1
699
93

Dermatology
366
34
6
10
11.23
16.41
0.8552
9,588
4
364
125

Vote
435
16
2
8
6.41
10.81
0.8713
47,102
1
432
93

Nursery
12,960
8
5
3
5.03
5.67
0.4156
5,721,840
1
12,960
2,543

Chess
3,196
36
2
9
9.65
10.35
0.6004
2,395,174
1
2,389
2,012

Heart
303
13
5
5
6.58
7.85
0.4719
7,755
2
302
94

The column R shows the value of Hamming distance threshold estimated from the CDF (see Figure 3). AC is the accuracy of our CD-Clustering. We highlight the accuracy values that are larger than 0.8. The columns m, #comp, and top- display the number of edges in , the number of connected components in , and the total number of data points in top- clusters, respectively. Except Mushroom and Chess datasets, the top- clusters detected by CD-Clustering include all or nearly all the data points. This result verifies the effectiveness of the simple estimation of and the Louvain method. Finally, the column Runtime shows the runtime of CD-Clustering in millisecond which is almost linear in .

5.2. Evaluation Metrics

To evaluate the performance of clustering algorithms, we use the same metrics as in [8, 9, 15]. If dataset contains classes for a given clustering, let denote the number of data objects that are correctly assigned to class , let denote the data objects that are incorrectly assigned to the class , and let denote the data objects that are incorrectly rejected from the class . The precision, recall, and accuracy are defined as

We demonstrate how to find the best confusion matrix and compute the precision, recall, and accuracy metrics in the following example.

Example 3. Assume that a dataset of objects clustered in clusters with the ground-truth and predicted cluster labels as in Table 3.
To find the best confusion matrix , we evaluate mappings from the set predicted labels to the ground-truth . For example, the mapping gives us the confusion matrix in Table 4. The value in each cell, for example, , is the number of pairs appearing in Table 3. Note that the sum of each column is equal to the number of objects in the corresponding cluster. The values of precision, recall, and accuracy are

The best mapping in this case is with , , and .

Table 3: Ground-truth and predicted labels.

Object id
1
2
3
4
5
6
7
8
9
10

Ground-truth label
1
1
1
2
2
2
2
3
3
3

Predicted label
b
b
a
b
a
c
b
a
a
c

Table 4: A confusion matrix.

1
2
3

c
0
1
1

a
1
1
2

b
2
2
0

5.3. Clustering Results

For comparison, we choose the algorithms by Cao et al. [8] and Khan and Ahmad [9] as well as the random -modes [3]. We rerun the Java implementation provided in [9] and get a confusion matrix for each dataset. Then we find the best evaluation metrics using the brute-force technique in Example 3. Surprisingly, the metrics for seven datasets reported in [9] are not so good. They only match for the case of Vote data and get better value for Soybean and worse values on the other five datasets. For Cao’s algorithm, our C++ implementation provides the matching results on three out of four datasets tested in [8], namely, Soybean, Mushroom, and Breast-Cancer. The worse metrics appear on Zoo data. However, our results agree with the Python implementation of Cao’s algorithm at [27]. The results for random -modes with 10,000 runs/dataset are also more or less different from [8, 9].

The clustering results for the ten categorical datasets are summarized in Tables 5–14. In terms of accuracy, precision, and recall, our scheme achieves the following results:

(i)Accuracy: our scheme outperforms or equals other methods in 7 cases, in particular with large margins in Lung-Cancer, Breast-Cancer, Dermatology, and Nursery datasets.(ii)Precision: our scheme outperforms or equals other methods in 7 cases.(iii)Recall: our scheme outperforms or equals other methods in 7 cases.

Table 5: Clustering results for soybean small data.

(a) Confusion matrix

Class

D1
D2
D3
D4

D1
10
0
0
0

D2
0
10
0
0

D3
0
0
10
0

D4
0
0
0
17

(b) Performance comparison

Random
Cao
Khan
Proposed

AC
0.8044
1
0.9787
1

PR
0.7969
1
0.9773
1

RE
0.8005
1
0.9853
1

Table 6: Clustering results for Mushroom data.

(a) Confusion matrix

Class

Poisonous
Edible

Poisonous
4093
2124

Edible
115
1792

(b) Performance comparison

Random
Cao
Khan
Proposed

AC
0.7206
0.8754
0.8288
0.7244

PR
0.7448
0.9019
0.8688
0.7990

RE
0.7167
0.8709
0.8228
0.7151

Table 7: Clustering results for Zoo data.

(a) Confusion matrix

Class

a
b
c
d
e
f
g

a
37
0
0
0
0
0
0

b
0
13
0
0
0
0
1

c
0
0
20
0
0
0
1

d
0
0
0
9
8
0
0

e
4
0
0
0
0
0
0

f
0
0
0
0
0
4
3

g
0
0
0
1
0
0
0

(b) Performance comparison

Random
Cao
Khan
Proposed

AC
0.7041
0.6733
0.8614
0.8218

PR
0.5876
0.5996
0.7390
0.5688

RE
0.5893
0.6233
0.7648
0.6861

Table 8: Clustering results for Lung-Cancer data.

(a) Confusion matrix

Class

a
b
c

a
5
2
2

b
5
7
1

c
3
0
7

(b) Performance comparison

Random
Cao
Khan
Proposed

AC
0.5227
0.5313
0.4375
0.5938

PR
0.5590
0.5833
0.4468
0.5980

RE
0.5283
0.5393
0.4470
0.6208

Table 9: Clustering results for Breast-Cancer data.

(a) Confusion matrix

Class

Benign
Malignant

Benign
432
8

Malignant
26
233

(b) Performance comparison

Random
Cao
Khan
Proposed

AC
0.8174
0.9113
0.6323
0.9514

PR
0.8283
0.9292
0.5535
0.9407

RE
0.7996
0.8773
0.5336
0.9550

Table 10: Clustering results for Dermatology data.

(a) Confusion matrix

Class

Seborrheic dermatitis
Psoriasis
Lichen planus
Chronic dermatitis
Pityriasis rosea
Pityriasis rubra pilaris

Seborrheic dermatitis
61
0
2
0
49
0

Psoriasis
0
111
0
0
0
0

Lichen planus
0
0
70
0
0
0

Chronic dermatitis
0
1
0
52
0
0

Pityriasis rosea
0
0
0
0
0
1

Pityriasis rubra pilaris
0
0
0
0
0
19

(b) Performance comparison

Random
Cao
Khan
Proposed

AC
0.5683
0.5984
0.6175
0.8552

PR
0.5318
0.5548
0.6841
0.7543

RE
0.5028
0.5393
0.6165
0.8189

Table 11: Clustering results for Nursery data.

(a) Confusion matrix

Class

Not_recom
Recommend
Very_recom
Priority
Spec_prior

Not_recom
1440
0
132
1484
1264

recommend
0
0
0
0
0

Very_recom
0
0
0
0
0

Priority
1440
2
196
1924
758

Spec_prior
1440
0
0
858
2022

(b) Performance comparison

Random
Cao
Khan
Proposed

AC
0.3331
0.3673
0.2804
0.4156

PR
0.2902
0.2978
0.2304
0.6494

RE
0.2592
0.2273
0.2044
0.2569

Table 12: Clustering results for Congressional Vote data.

(a) Confusion matrix

Class

Republican

Democrat

Republican
160

48

Democrat
8

219

(b) Performance comparison

Random
Cao
Khan
Proposed

AC
0.8603
0.8644
0.8506
0.8713

PR
0.8554
0.8568
0.8484
0.8670

RE
0.8732
0.8730
0.8672
0.8863

Table 13: Clustering results for Chess data.

(a) Confusion matrix

Class

Win

Nowin

Win
1562

0

Nowin
1277

357

(b) Performance comparison

Random
Cao
Khan
Proposed

AC
0.6390
0.7400
0.7040
0.6004

PR
0.5184
0.5449
0.5312
0.6092

RE
0.5394
0.5806
0.5540
0.7751

Table 14: Clustering results for Heart-Disease data.

(a) Confusion matrix

Class

0
1
2
3
4

0
99
9
0
1
0

1
24
10
4
2
2

2
14
25
30
28
8

3
20
9
1
2
1

4
7
2
1
2
2

(b) Performance comparison

Random
Cao
Khan
Proposed

AC
0.3895
0.3069
0.4422
0.4719

PR
0.3159
0.2763
0.3413
0.3271

RE
0.3219
0.2641
0.3467
0.3660

To better understand the performance of CD-Clustering, we revisit Table 2. There is a strong correlation between the accuracy metric and the gap between , avg.intra.dist and avg.inter.dist. If the ground-truth average intracluster and intercluster distances are far apart and is close to the former distance, we can get high accuracy (larger than 0.8). This is the cases of Soybean, Zoo, Breast-Cancer, Dermatology, and Vote. The two datasets with the lowest accuracy Nursery and Heart have smallest gaps between the ground-truth intracluster and intercluster distances. The three remaining datasets have medium accuracy despite the small distance gap. Out of the ten datasets, our CD-Clustering performs worst, that is, only comparable to or worse than the random -modes, on Mushroom and Chess. This is reflected in the ratio of top- to : 5,366/8,124 (Mushroom) and 2,389/3,196 (Chess). Also, is equal to 2 in these two datasets. These facts suggest that when and the intra/intercluster distance gap are both small, CD-Clustering must struggle harder for the top- communities.

6. Conclusion

Rather than using the -modes algorithm with heuristic initialization methods, we propose in this paper a novel clustering scheme CD-Clustering for categorical data. By applying the Louvain method, a widely used community detection technique, CD-Clustering can uncover the highly homogeneous groups of categorical data points using only the distance information. CD-Clustering builds the simple graph by limiting all pairwise Hamming distances by a threshold which is estimated simply using the number of clusters and the distance distribution. The evaluation against two -modes initialization techniques confirms the effectiveness of CD-Clustering. In future work, we plan to reduce the complexity of CD-Clustering for better scalability.

Notations

: | Dataset with data points
: | Set of categorical attributes
: | modes of
: | Number of clusters
: | Hamming distance between and
: | Hamming distance threshold
: | Simple graph for with parameter .

Conflicts of Interest

The author declares that there are no conflicts of interest regarding the publication of this paper.

References

A. K. Jain, “Data clustering: 50 years beyond K-means,” Pattern Recognition Letters, vol. 31, no. 8, pp. 651–666, 2010.

S. P. Lloyd, “Least squares quantization in PCM,” Institute of Electrical and Electronics Engineers Transactions on Information Theory, vol. 28, no. 2, pp. 129–137, 1982.

Z. Huang, “Extensions to the k-means algorithm for clustering large data sets with categorical values,” Data Mining and Knowledge Discovery, vol. 2, no. 3, pp. 283–304, 1998.

D. Arthur and S. Vassilvitskii, “k-means++: the advantages of careful seeding,” in Proceedings of the ACM-SIAM Symposium on Discrete Algorithms, pp. 1027–1035, 2007.

B. Bahmani, B. Moseley, A. Vattani, R. Kumar, and S. Vassilvitskii, “Scalable κ-means++,” Proceedings of The VLDB Endowment, vol. 5, no. 7, pp. 622–633.

O. Bachem, M. Lucic, S. H. Hassani, and A. Krause, “Approximate K-Means++ in sublinear time,” in Proceedings of the 30th AAAI Conference on Artificial Intelligence, AAAI 2016, pp. 1459–1467, usa, February 2016.

L. Bai, J. Liang, C. Dang, and F. Cao, “A cluster centers initialization method for clustering categorical data,” Expert Systems with Applications, vol. 39, no. 9, pp. 8022–8029, 2012.

F. Cao, J. Liang, and L. Bai, “A new initialization method for categorical data clustering,” Expert Systems with Applications, vol. 36, no. 7, pp. 10223–10228, 2009.

S. S. Khan and A. Ahmad, “Cluster center initialization algorithm for K-modes clustering,” Expert Systems with Applications, vol. 40, no. 18, pp. 7444–7456, 2013.

S. Wu, Q. Jiang, and J. Z. Huang, “A new initialization method for clustering categorical data,” in Proceedings of the Pacific-Asia Conference on Knowledge Discovery and Data Mining, pp. 972–980, Springer, 2007.

S. Fortunato, “Community detection in graphs,” Physics Reports, vol. 486, no. 3-5, pp. 75–174, 2010.

V. D. Blondel, J. Guillaume, R. Lambiotte, and E. Lefebvre, “Fast unfolding of communities in large networks,” Journal of Statistical Mechanics: Theory and Experiment, vol. 2008, no. 10, Article ID P10008, 2008.

F. Cao, J. Liang, D. Li, L. Bai, and C. Dang, “A dissimilarity measure for the k-modes clustering algorithm,” Knowledge-Based Systems, vol. 26, no. 9, pp. 120–127, 2012.

Z. He, S. Deng, and X. Xu, “Improving K-Modes Algorithm Considering Frequencies of Attribute Values in Mode,” in Computational Intelligence and Security, vol. 3801 of Lecture Notes in Computer Science, pp. 157–162, Springer Berlin Heidelberg, Berlin, Heidelberg, 2005.

M. K. Ng, M. J. Li, J. Z. Huang, and Z. He, “On the impact of dissimilarity measure in k-modes clustering algorithm,” IEEE Transactions on Pattern Analysis and Machine Intelligence, vol. 29, no. 3, pp. 503–507, 2007.

H. Zhou, Y. Zhang, and Y. Liu, “A Global-Relationship Dissimilarity Measure for the,” Computational Intelligence and Neuroscience, vol. 2017, pp. 1–7, 2017.

M. E. J. Newman and M. Girvan, “Finding and evaluating community structure in networks,” Physical Review E: Statistical, Nonlinear, and Soft Matter Physics, vol. 69, no. 2, Article ID 026113, pp. 1–26113, 2004.

A. Clauset, M. E. J. Newman, and C. Moore, “Finding community structure in very large networks,” Physical Review E: Statistical, Nonlinear, and Soft Matter Physics, vol. 70, no. 6, Article ID 066111, 2004.

A. Medus, G. Acuña, and C. O. Dorso, “Detection of community structures in networks via global optimization,” Physica A: Statistical Mechanics and its Applications, vol. 358, no. 2-4, pp. 593–604, 2005.

M. E. J. Newman, “Finding community structure in networks using the eigenvectors of matrices,” Physical Review E: Statistical, Nonlinear, and Soft Matter Physics, vol. 74, no. 3, Article ID 036104, 2006.

P. Pons and M. Latapy, “Computing communities in large networks using random walks,” Lecture Notes in Computer Science (including subseries Lecture Notes in Artificial Intelligence and Lecture Notes in Bioinformatics): Preface, vol. 3733, pp. 284–293, 2005.

J. Reichardt and S. Bornholdt, “Statistical mechanics of community detection,” Physical Review E: Statistical, Nonlinear, and Soft Matter Physics, vol. 74, no. 1, Article ID 016110, 2006.

U. N. Raghavan, R. Albert, and S. Kumara, “Near linear time algorithm to detect community structures in large-scale networks,” Physical Review E: Statistical, Nonlinear, and Soft Matter Physics, vol. 76, no. 3, Article ID 036106, 2007.

M. Rosvall and C. T. Bergstrom, “Maps of random walks on complex networks reveal community structure,” Proceedings of the National Acadamy of Sciences of the United States of America, vol. 105, no. 4, pp. 1118–1123, 2008.

B. J. Frey and D. Dueck, “Clustering by passing messages between data points,” American Association for the Advancement of Science: Science, vol. 315, no. 5814, pp. 972–976, 2007.

C. L. Blake and C. J. Merz, Uci repository of machine learning databases, vol. 55, University of california. Department of Information and Computer Science, Irvine, Calif, USA, 1998.

Python implementations of the k-modes and k-prototypes clustering algorithms, for clustering categorical data, https://github.com/nicodv/kmodes.