{'fraction_non_alphanumeric': 0.024461729230075526, 'fraction_numerical': 0.004170893924022094, 'mean_word_length': 4.747651441528992, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, '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}}
Comparing Model-based Versus K-means Clustering for the Planar Shapes

In some fields, there is an interest in distinguishing different geometrical objects from each other. A field of research that studies the objects from a statistical point of view, provided they are invariant under translation, rotation and scaling effects, is known as the statistical shape analysis. Having some objects that are registered using key points on the outline of the objects, the main purpose of this paper is to compare two popular clustering procedures to cluster objects. We also use some indexes to evaluate our clustering application. The proposed methods are applied to the real life data.


Introduction
In some fields there is an interest for distinguishing different images from each other which is known as image analysis or image clustering and classification. Generally speaking, it's not necessary to know if the image has specific shapes, such as human face, specific parts of human body, organic tissues and son on. Instead, just the pixels are relatively compared in these cases and finally images are assigned into different groups with distinguishable properties for each group. Of course, if there is some information about particular aspects of the image, they can be helpful for further statistical analysis. As an example, consider the Figure 1, in which there are some pictures of gorilla skulls. It worths to mention that the data were first studied by [10]. One can grasp some information from these images in terms of their sizes and shapes.
One of the interesting questions in studying these skulls is: "how can these pictures be put in two different groups?". A field of research for answering such typical questions from statistical point of view has its root in multivariate analysis. However, those geometrical aspects of the object lie in the statistical shape analysis which was first introduced to the statistical communities by [8] in an interesting article titled "The Diffusion of Shape".
In fact, data in the statistical shape analysis terminologies are the shape of the objects. Hence, particular geometrical aspects of the objects such as topological structure should be considered in the statistical analysis. One of main concepts of trivial statistical analysis for any real data sets is related to the way one views the data. Generally speaking, the observations can be viewed either as the realizations of the random variables generated from some particular distributions which leads to the parametric statistics, or can be seen as data from some unknown densities turning to the non-parametric statistics. These two views in clustering the objects; confined in the statistical shape analysis, are compared with each other in this article. The main is to discover how they are successful in clustering pre-labeled planar objects. In this paper, a background of the statistical shape analysis and the related definitions are first presented. Then, two clustering methods applied for the planar shapes are described. Some simulation studies along with real application of proposed methods are included in the final section. Moreover, general conclusions and some possible further researches arising from current study are given.

A Background on the Landmark-based Shape Analysis
It worths to recall the formal definition of shape before going forward on further analyzing the images of the objects. It has mainly been given for the statistical analysis of the shapes. Kendall [8] provided the following definition: Definition 2.1. Shape is any geometrical information of object after removing translation, scale and rotation.
Based upon this definition, all homologous images are considered to be in one class and so can be represented as just one object. From this point of view, one encounters with the equivalent classes and the consequence mathematical theories arise. One can consult [3] for more details on this and other relevant topics.
Taking the images of the objects, one can follow different methods to study them statistically. At the first instance, one should define particular variables as the representative of the picture (image) of the objects. One of the simplest procedures to do this in the statistical shape analysis context is to set some points in specific parts of the image. Those points are called as the landmarks and the statistical analysis using them is known as the landmark-based analysis. The Cartesian coordinates of the points are the observations of the variables defined in the statistical shape analysis framework. A typical illustration of such method is shown in Figure 2. As expected one can work with the matrices constituting the Cartesian coordinates instead of the whole images. Each of such matrix is then called configuration matrix. At the end, one has a set of matrices and should analyze them using the common statistical tools.
According to the statistical definition of the shape given above, some steps should be followed to get the shapes of the objects. In another word, the configuration matrices are not defining the equivalent classes of the objects in their initial constructions. Invoking many mathematical operations, some particular transformations should be performed on the configuration matrices in order to achieve the shapes of the objects. Those relevant transformations are similarity transformations, which include translation, scale and rotation effects. Theoretically, these operations transfer the configuration matrices from the Euclidean space to a non-Euclidean space. This latter space is known as shape space and is usually identified by different systems of coordinates. Two well-known systems are Kendall [9], and Bookstein coordinates [1]. Those coordinates are now bases for statistical analysis such as clustering. To have an idea of employing these stages to get the shape coordinates, we explain those procedures applied for the Figure 2.
Suppose the landmarks set on the Figure 2 are represented in a configuration matrix, say A, as follows: By pre-multiplying the matrix A by Helmert sub-matrix, H, the translation effect is removed. Rotation and scale are omitted using rotation matrix and the common Euclidean norm, respectively. Generally, for removing all of similarity effects from the planar objects A, the following equality is useful: is the Bookstein shape coordinates of the objects in the Figure 2 with the landmarks set in A.
As a remark, we can imagine the case in which the points in the equivalent classes can be separated into some cluster in which other categorical variables are assisting to separate the objects. In another word, the way in which the shapes of the objects are different in terms of one the nominal variables worths to study. To do this, one go through either parametric or non-parametric procedures. As a candidate for each scenarios, we confine ourselves to the modelbased and k-means clustering in this paper. Furthermore, we just consider the planar shapes, i.e. 2-D objects.

Clustering the Planar Shapes
Clustering objects can be done using three distinct methods. For our shape analysis application, we utilize two of them below.
3.1. Model-based clustering of shapes. This approach for clustering shape data was just recently introduced by [7]. Below, we highlight the main theme of their research which is useful for our further statistical analysis.
As the first stage, one needs to model the random behavior of the landmarks for each objects by some distributions. Suppose the vector resulted from stacking columns of the matrix A has the multivariate normal distribution. It is shown in [4] that the distribution of u is then the offset normal with the density function where the components can be achieved by following sets of the formulas: Here, E(ι p |b, c) is the p-th momentum of the normal distribution with the mean b and variance c, i.e . N (b, c), which according to [11] can be derived using the following recursive equality: The parameters in the density f u (u; µ, Σ) can be estimated through employing the EM algorithm [2].
To invoke the model-based clustering of the planar shapes, it is assumed the observations, i.e. the shape coordinates, come from a mixture of distributions. In particular, where each distribution shows a separate group and each observation is assumed to come only from one of M densities. By estimating the parameters π mi and the other parameters in the model, one can assign the observations to each group in a trivial manner. More details on this can be found in [7].
3.2. K-means clustering of shapes. One of the popular non-parametric approach for clustering the objects is k-means clustering. Using this method, the number of clusters (groups), i.e. k, is fixed initially. So, one encounters with the observations set in k distinct clusters. Then, the centroid, usually means of shapes , for each group are computed. Obviously, the optimal situation is occurred on allocating each observation to the nearest group in sense which its distance with the centroid of the cluster is minimal. To reach this objective, one observation is repeatedly removed from each group and added to another cluster until there is no noticeable change in Within Sum of Squares of the Groups (WGSS). The main difference between various versions of the k-means clustering arises from the different distance measures used in computing the WGSS. There are some algorithms to handle this substitution and insertion in a proper way.
Since the shape data are members of a non-Euclidean space, calculating distance between them cannot be done using the common Euclidean metrics. Instead, some distances, which are appropriate to measure the difference between shape data and applicable in the shape space, should be utilized. A comprehensive account of those distances are provided in [4]. Below, we review some of them which are useful for our analysis. In all definitions given bellow, the X 1 and X 2 represent two objects, represented by their corresponding configuration matrices.
Definition 3.1. The full procrustes distance between X 1 and X 2 is Definition 3.2. The partial Procrustes distance between X 1 and X 2 is defined as Definition 3.4. Tangent space distance between X 1 and X 2 is the distance between corresponding two points mapped into the planar tangent space which is the linearized version of the shape space in the vicinity of a particular point (usually mean shape) of shape space.
Definition 3.5. Size-and-shape distance is the distance between the sizeand-shape forms of the configurations and is found by minimizing the Euclidean distance over rotations: From practical point of view, we follow algorithm proposed by [5]. In fact, this algorithm works only for Euclidean distance and so it should be adapted for the shape data with the aforementioned distances.

Simulation Studies and Real Data Analysis
In order to compare two proposed methods on clustering the shapes data, we need to recall some relevant criteria. Those validation measures can be found in [6]. Among many of them, we consider one of the simple criteria in this paper. Coinciding the consequence of a clustering procedure with the distinctions of the data made by the initial categorical labels is the core root of the clustering validation indexes. This objective is properly adopted into the CV I, defined as follows where TCO stands for the True Clustered Observations and TO for the Total Observations. Next, we provide our simulation studies to compare two aforementioned shape clustering procedures.

Simulation Studies.
In order to conduct the simulation studies, we assume that there are two types of data differentiated by the male and female labels. In fact, the objects were simulated in such a way that they can mimic the real data described in the next section. A schematic representation of these data can be seen in Figure 3. One can efficiently compute the sample mean and variance of the real data. Mathematical treatment of this is provided in [3] and codes to do this task are given in [4]. Then, one can simulate the data using those summary statistics. Hence, mimicking pattern within and between each group of shape data will occur. Note that simulated data can also be generated using the multivariate normal distribution with the mean and variance parameters to be the same as those for the real data. Then, the entire observations need to be transformed to the offset-normal density to assure having shape data. One can consulate [3] for more details.
The structure of our simulation studies are as follows. The 50 samples were simulated for the pair of gorilla and orangutan skulls identified with eight landmarks. Hence, there are 100 samples for each type of the skulls. First, the model-based clustering of the shape data was invoked on these objects and the CVI was derived. This scenario was repeated for 100 iterations. Then, the k-means clustering procedure was performed using the same data. The results (a) (b) Figure 3. The shape of simulated data. They are generated such that their shapes are mimicking the gorilla (a) and orangutan (b) skulls.
gained in this study are shown in the Table 1. As seen, the results for the Euclidean distance is also included for a proper comparison purposes. As the Table 1 shows we see different behaviour for two objects. For the gorilla-like simulated data, the model-based was weaker than the k-means even using various distances. However, this is not the case for the orangutan-like simulated data. Confining to the k-means clustering, the Euclidean distance outperforms the other distances for the gorilla-like data. For the orangutanlike data, the candidate is the size-and-shape distance. Generally, it might be argued that the size-and-shape distance is a reasonable distance to use whenever the size is playing the key role on identifying the geometrical structure of the objects. On the other hand, if this is not the case, one can ignore the structure of the shape space and switch to the common multivariate statistics via projecting the shape data into the Euclidean space in the vicinity of the mean shape.

4.2.
Real data analysis. In this section, we consider the real data set to check the performance of two clustering methods. The data contain 59 samples (29 male and 30 female) for gorilla skulls and 54 samples (30 male and 24 female) for the orangutan. The data are available in the package shapes; freely available in the software R.
Unfortunately, the model-based method did not work and the algorithm failed repeatedly while calculating the results. However, the k-means method performed reasonably well. The results are appeared in the Table 2. The reported data in the table show that the size-and-shape outperforms the other distances, although there is not too much difference between the CVI of this and Euclidean distance for the gorilla data. However, this difference is remarkable for the gorilla shapes. The interesting point goes back to the same values of the CVI for the full procrustes and riemannian regardless of the type of the data. However, there is still room to investigate the difference of shape clustering via relating it to the relevant covariates. Also, adopting the available software packages that are implementing the clustering data for the shape objects which are members of the non-Euclidean space is vital. This will help the researchers to get more insights into the clustering of the objects and facilities to compare clustering methods.

Conclusion and Future Works
Shape as the data play a great role in various scientific fields. The main objects of this paper was to study and compare two well-known clustering methods applied for the shape objects. These typical data are members of a non-Euclidean space and so invoking clustering methods require a great care. We investigated the methods in both simulation and real application studies.
The results gained from applying the model-based method show that the performance of clustering for simulated samples from normal distributions is promising. This means that, if we have observations with normal distribution (which can be evaluated using, for example, the normality tests), we can use model-based clustering. The interesting point is that if one is away from the normality assumption, the performance of the model-based clustering gets weaker.
The results gained from applying k-means method show that size-and-shape distance, among different distances, has better results. This might be because of considering size of the shapes which is important in differentiating between male and female sexes. It means that we are not allowed to remove all of the similarity effects to compare shapes whenever there is clear difference between groups. As seen, the investigation in this paper consists of two different sections, i.e. simulation study and real data analysis. Further, both real data sets are discriminated in terms of male and female genders. It means that we have two apparent clusters in our real-life data analysis. Moreover, we have followed the same structure inherited among the real data in our simulation study. So, there is no concern on selecting the numbers of clusters in our investigation. However, this is the case in where there is no prior knowledge on explicit numbers of the clusters. Discussion on this critical issue is out of the scope of our paper. There are some directions to extend the current research. A well-known distribution in the shape analysis context is the size-and shape offset normal. One can consider it for clustering the shape and conduct new research in this context rather than using the offset normal distribution in our study.