{'fraction_non_alphanumeric': 0.030401448195080397, 'fraction_numerical': 0.005058034288148227, 'mean_word_length': 4.476093294460641, 'pattern_counts': {'":': 0, '<': 1, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Hierarchical Aggregation Approach for Distributed clustering of spatial datasets

In this paper, we present a new approach of distributed clustering for spatial datasets, based on an innovative and efficient aggregation technique. This distributed approach consists of two phases: 1) local clustering phase, where each node performs a clustering on its local data, 2) aggregation phase, where the local clusters are aggregated to produce global clusters. This approach is characterised by the fact that the local clusters are represented in a simple and efficient way. And The aggregation phase is designed in such a way that the final clusters are compact and accurate while the overall process is efficient in both response time and memory allocation. We evaluated the approach with different datasets and compared it to well-known clustering techniques. The experimental results show that our approach is very promising and outperforms all those algorithms


I. INTRODUCTION
Spatio-temporal datasets are often very large and difficult to analyse [1]. Traditional centralised data management and mining techniques are not adequate, as they do not consider all the issues of data-driven applications such as scalability in both response time and accuracy of solutions, distribution and heterogeneity [2]. In addition, transferring a huge amount of data over the network is not an efficient strategy and may not be possible for security and protection reasons.
Distributed data mining (DDM) techniques constitute a better alternative as they are scalable and can deal efficiently with data heterogeneity. Many DDM methods such as distributed association rules and distributed classification have been proposed in the last decade and most of them are based on performing partial analysis on local data at individual sites followed by the generation of global models by aggregating those local results [3], [4], [5], [6]. However, only a few of them concern distributed clustering. Among these many parallel clustering algorithms have been proposed [7], [8], [9]. They are classified into two categories. The first consists of methods requiring multiple rounds of message passing and significant amount of synchronisations. The second category consists of methods that build local clustering models and then aggregate them to build global models [10]. Most of the parallel approaches need either multiple synchronisation constraints between processes or a global view of the dataset, or both [11], [12]. For distributed approaches, the aggregation phase is very costly, and therefore, it needs to be optimised.
In this paper, we present an approach that reduces the complexity of the aggregation phase. It reduces significantly the amount of information exchanged during the aggregation phase, and generates automatically the correct number of clusters. In a case study, it was shown that the data exchanged is reduced by more than 98% of the original datasets.

II. DYNAMIC DISTRIBUTED CLUSTERING
The DDC approach includes two main steps. In the first step, as usual, we cluster the datasets located on each node and select good local representatives for each local cluster. This phase is executed in parallel without communications between the nodes. In this phase we can reach a super speedup. The next phase consists of aggregating the local clusters. This operation is executed by certain nodes of the system, called leaders. The leaders are elected according to some nodes' characteristics such as their capacity, processing power, connectivity, etc. The leaders are responsible for merging and regenerating the data objects based on the local cluster representatives. However, the nodes need to communicate in order to send their local clusters to the leaders. This process is shown in Figure 1.

A. Local Models
Each node can use any technique of clustering on its local dataset. This is one of the key features of this approach to deal with data heterogeneity. Each node choses a technique that is more suitable for its data. This approach relaxes the data pre-processing. For instance we may not need to deal with data consistency between the nodes' datasets. All needed is the consistency of the local cluster's representation. Once extracted the local clusters will be used as inputs for the next phase to generate global clusters. However exchanging the local clusters through the network will create significant overheads and slowdown hugely the process. This is one of the major problems of the majority of distributed clustering techniques. To improve the performance we propose to exchange a minimum number of points/objects. Instead of sending all the clusters datapoints, we only exchange their representative points, which constitute 1% to 2% of the total size of the dataset.
The best way to represent a spatial cluster is by its shape and density. The shape of a cluster is represented by its boundary points (called contour) [11], [13], [14] (see Figure  4). Many algorithms for extracting the boundaries from a cluster can be found in the literature [15], [16]. Recently, we developed a new algorithm for detecting and extracting the boundary of a cluster [10]. The main concepts of this technique are given below.

Neighbourhood:
Given a cluster C ⊆ n ≡ {p 1 , p 2 , ..., p n } The neighbourhood N C (p) of a point p in the cluster C is defined as the set of points p i ∈ C so that the distance between p i and p is less than or equal to ε: In order to determine the boundary points of a cluster, we need to introduce the following concepts: Displacement vector: A displacement vector from p i ∈ N C (p) to the point p is defined as: This vector points towards the area of the lowest density of the neighbourhood of p.
Balance vector: The balance vector relative to the point p is defined as follows: Note that the balance vector of p points to the least dense area of the neighbourhood of p, the length of the vector does not hold any relevant information. Figure 2 shows an example of a balance vector. The neighbourhoods of p are inside the circle, the balance vector is represented by the blue colour.
Boundary points: If a point is a boundary point, there should be no points towards the direction of the balance vector. This property allows us to separate boundary points and internal points. For each point p, it checks for an empty area whose shape is the intersection of an hyper-cone of infinite height, vertex, axis and aperture ρ, where ρ is a given angle. As shown in 3, the area checked is highlighted in green. Formally, a boundary point is described as a Boolean predicate.
We can define the boundary B C of a cluster C as the set of all boundary points in C: The algorithm for selecting the boundary points is described in Algorithm 1, and its complexity is O(n log n).

Algorithm 1: Boundary Detection Algorithm
Let C i be a set of clusters of node i and B cj be the boundary of a cluster c j ∈ C i . The local model L i is defined by: Where P i is the set of internal representatives.

B. Global Models
The global clusters are generated during the second phase. This phase consists of two main steps: 1) each leader collects the local clusters of its neighbours, 2) the leaders merge the local clusters using the overlay technique. The process of merging clusters will continue until we reach the root node. The root node will contain the global clusters (see Figure 1). During this phase we only exchange the boundaries of the clusters.
The merging process consists of two steps: boundary merging and regeneration. The merging is performed by a boundary-based method. Let L i be a local model received from the site i and B i be the set of all boundaries in L i . The global model G is defined by: where Γ is a merging function.

III. DDC EVALUATION AND VALIDATION
DDC is evaluated using different clustering algorithms. In this paper we use a centroid-based algorithm (K-Means) and a density-based Algorithm (DBSCAN).

A. DDC-K-Means
The DDC with K-Means (DDC-K-Means) is characterised by the fact that in the first phase, called the parallel phase, each node N i of the system executes the K-Means algorithm on its local dataset to produce L i local clusters and calculate their contours. The rest of the process is the same as described above. It was shown in [17] that DDC-K-Means dynamically determines the number of the clusters without a priori knowledge about the data or an estimation process of the number of the clusters. DDC-K-Means was compared to two wellknown clustering algorithms: BIRCH [18] and CURE [19]. The results showed that it generates much better clusters. Also, as expected, this approach runs much faster than the two other algorithms; BIRCH and CURE.
DDC-K-Means does not need the number of global clusters in advance. It is calculated dynamically. Moreover, each local clustering L i needs K i . LetK i be the exact number of local clusters in the node N i , all it is required is to set K i such that K i >K i . This is much simpler than giving K i , especially when there is not enough knowledge about the local dataset characteristics. Nevertheless, it is indeed better to set K i as close as possible toK i in order to reduce the processing time in calculating the contours and also merging procedure.
However, DDC-K-Means fails to find good clusters for datasets with Non-Covex shapes and also for datasets with noises, this is due to the fact that the K-Means algorithm tends to work with convex shape only, because it is based on the centroid principle to generate clusters. Moreover, we can also notice that the results of DDC-K-Means are even worse with dataset which contains a big amount of noises (T 3 , and T 4 ). In fact it returns the whole dataset with the noise as one final cluster for each dataset (see Figure 5). This is because K-Means does not deal with noise.

B. DDC with DBSCAN
DBSCAN (Density-Based spatial Clustering of Applications with Noise) is a well-known density based clustering algorithm capable of discovering clusters with arbitrary shapes and eliminating noisy data [20]. 2) DDC-DBSCAN Algorithm: The approach remains the same; instead of using K-Means for processing local clusters, we use DBSCAN. Each node (n i ) executes DBSCAN on its local dataset to produce K i local clusters. Once all the local clusters are determined, we calculate their contours. The second phase is the same and the pseudo code of the algorithm is given in Algorithm 2. // N ode i joins its neighbourhood 4) Compare cluster of N ode i to other node's clusters in the same group; // look for overlapping between clusters.

5) j = ElectLeaderNode();
// Elect a node which will merge the overlapping clusters. if i <> j then Send (contour i, j); else if level > 0 then level --; Repeat 3, 4, and 5 until level=0; else return (K g : N ode i ' clusters); Figure 4 illustrates an example of DDC-DBSCAN. Assume that the distributed computing platform contains five Nodes (N = 5). Each Node executes DBSCAN algorithm with its local parameters (Eps i , M inP ts i ) on its local dataset. As it can be seen in Figure 4 the new approach returned exactly the right number of clusters and their shapes. The approach is insensitive to the way the original data was distributed among the nodes. It is also insensitive to noise and outliers. As we can see, although each node executed DBSCAN locally with different parameters. The global final clusters were correct even on the noisy dataset (T 3 ) (See Figure 4).

IV. EXPERIMENTAL RESULTS
In this section, we study the performance of the DDC-DBSCAN approach and demonstrate its effectiveness compared to BIRCH, CURE and DDC-K-Means. We choose these algorithms because either they are in the same category such as BIRCH which belongs to hierarchical clustering category, or have an efficient optimisation approach, such as CURE.
BIRCH: We used the BIRCH implementation provided in [18]. It performs a pre-clustering and then uses a centroidbased hierarchical clustering algorithm. Note that the time and space complexity of this approach is quadratic to the number of points after pre-clustering. We set its parameters to the default values as suggested in [18].

CURE:
We used the implementation of CURE provided in [19]. The algorithm uses representative points with shrinking towards the mean. As described in [19], when two clusters are merged in each step of the algorithm, representative points for the new merged cluster are selected from the ones of the two original clusters rather than all the points in the merged clusters.

A. Experiments
We run experiments with different datasets. We used four types of datasets (T 1 , T 2 , T 3 and T 4 ) with different shapes and sizes. These datasets are very well-known benchmarks to evaluate density-based clustering algorithms. All the four datasets are summarised in Table I. The number of points and clusters in each dataset is also given. These four datasets contain a set of shapes or patterns which are not easy to extract with traditional techniques.

B. Quality of Clustering
We run the four algorithms on the Four datasets in order to evaluate the quality of their final clusters. Figure 5 shows the clusters returned by each of the four algorithms for the datasets without noise (T 1 ) and datasets with noise (T 2 , T 3 , and T 4 ). We use different colours to show the clusters returned by each algorithm.
As expected, BIRCH could not find correct clusters; it tends to work slightly better with datasets without noise (T 1 ), as BIRCH does not deal with noise. The results of CURE are worse and it is not able to extract clusters with non-convex shapes. We can also see that CURE does not deal with noise. DDC-K-Means fails to find the correct final results. In fact it returns the whole original dataset as one final cluster for each dataset (T 3 and T 4 ) (Which contain significant amount of noise). This confirms that the DDC technique is sensitive to the type of the algorithm chosen for the first phase. Because the second phase deals only with the merging of the local clusters whether they are correct or not. This issue is corrected by the DDC-DBSCAN, as it is well suited for spatial datasets with or without noise. For datasets with noise it eliminates the noise and outliers. In fact, it generates good final clusters in datasets that have significant amount of noise.
As a final observation, these results prove that the DDC framework is very efficient with regard to the accuracy of its results. The only issue is to choose a good clustering algorithm for the first phase. This can be done by exploring the initial datasets along with the question to be answered and choose an appropriate clustering algorithm accordingly.
Moreover, as for the DDC-K-Means, DDC-DBSCAN is dynamic (the correct number of clusters is returned automatically) and efficient (the approach is distributed and minimises the communications).

C. Speed-up
The goal here is to study the execution time of the four algorithms and demonstrate the impact of using a parallel and distributed architecture to deal with the limited capacity of a centralised system.
As mentioned in Section III-B1, the execution time for the DDC-DBSCAN algorithm can be generated in two cases. The first case is to include the time required to generate the distance matrix calculation. The second case is to suppose that the distance matrix has already been generated. The reason for this is that the distance matrix is calculated only once.   not include the time for post-processing since these are the same for the four algorithms.
As mentioned in Section III-B1, Table II confirmed the fact that the distance matrix calculation in DBSCAN is very significant. Moreover, DDC-DBSCAN's execution time is much lower than CUREs execution times across the four datasets. Table II shows also that the DDC-K-Means is very quick which is in line with its polynomial computational complexity. BIRCH is also very fast, however, the quality of its results are not good, it failed in finding the correct clusters across all the four datasets.
The DDC-DBSCAN is a bit slower that DDC-K-Means, but it returns high quality results for all the tested benchmarks, much better that DDC-K-Means, which has reasonably good results for convex cluster shapes and very bad results for non-convex cluster shapes. The overall results confirm that the DDC-DBSCAN clustering techniques compares favourably to all the tested algorithms for the combined performance measures (quality of the results and response time).

D. Computation Complexity
Let n be the number of data objects in the dataset. The complexity of our approach is the sum of the complexities of its three components: local mining, local reduction, and global aggregation. a) Phase1: Local clustering: Assume that the local clustering algorithm is DBSCAN for all the nodes. The cost of this phase is given by: Where N is the number of nodes in the system. The complexity of DBSCAN in the best case scenario is O(n log n) if the parameter Eps is chosen in a meaningful way and also if we exclude the distance matrix computation. Finally, the complexity of the local reduction algorithm is O(n log n). b) Phase2: Aggregation: Our global aggregation depends on the hierarchical combination of contours of local clusters. As the combination is based on the intersection of edges from the contours, the complexity of this phase is O(v log v + p). Where v is the number of vertices and p is the number of intersections between edges of different contours (polygons). c) Total complexity: The total complexity of our approach is T T otal = O(n log n) + O(n log n) + O(v log v + p), which is: In this paper, we proposed an efficient and flexible distributed clustering framework that can work with existing data mining algorithms. The framework has been tested on spatial datasets using the K-Means and DBSCAN algorithms. The proposed approach is dynamic, which solves one of the major shortcomings of K-Means or DBSCAN. We proposed an efficient aggregation phase, which reduces considerably the data exchange between the leaders and the system nodes. The size of the data exchange is reduced by about 98%.
The DDC approach was tested using various benchmarks. The benchmarks were chosen in such a way to reflect all the difficulties of clusters extraction. These difficulties include the shapes of the clusters (convex and non-convex), the data volume, and the computational complexity. Experimental results showed that the approach is very efficient and can deal with various situations (various shapes, densities, size, etc.).
As future work, we will try to extend the framework to non-spatial datasets. We will also look at the problem of the data and communications reduction during phase two.