Online updating of active function cross-entropy clustering

Gaussian mixture models have many applications in density estimation and data clustering. However, the model does not adapt well to curved and strongly nonlinear data, since many Gaussian components are typically needed to appropriately fit the data that lie around the nonlinear manifold. To solve this problem, the active function cross-entropy clustering (afCEC) method was constructed. In this article, we present an online afCEC algorithm. Thanks to this modification, we obtain a method which is able to remove unnecessary clusters very fast and, consequently, we obtain lower computational complexity. Moreover, we obtain a better minimum (with a lower value of the cost function). The modification allows to process data streams.


Introduction
Clustering plays a basic role in many parts of data engineering, pattern recognition, and image analysis.Some of the most important clustering methods are based on GMM, which in practice accommodates data with distributions that lie around affine subspaces of lower dimensions obtained by principal component analysis (PCA) [17], see Fig. 1a.However, by the manifold hypothesis, real-world data presented in high-dimensional spaces are likely to be concentrated in the vicinity of nonlinear sub-manifolds of lower dimensionality [4,30].The classical approach approximates this manifold by a mixture of Gaussian distributions.Since one non-Gaussian component can be approximated by a mixture of several Gaussians [10,35,38], these clusters are, in practice, represented by a combination of Gaussian components.This can be seen as a form of piecewise linear approximation, see Fig. 1a.Cross-entropy clustering (CEC) [34,36,37,40] approach gives similar result.
In [39], authors have constructed the afCEC (active function cross-entropy clustering) algorithm, which allows the clustering of data on sub-manifolds of ℝ d .The motivation comes from the observation that it is often profitable to describe nonlinear data by a smaller number of components with more complicated curved shapes to obtain a better fit of the data, see Fig. 1b.The afCEC method automatically reduces unnecessary clusters and accommodates nonlinear structures.
In this paper, the online version of the afCEC1 algorithm using Hartigan's approach is presented.In a case when a new point appears, we are able to update parameters of all clusters without recomputing all variables.Because we have to approximate complicated structures in each step, we have to construct a numerically efficient model.Therefore, we have chosen an approach that allows for the use of an explicit formula in each step.
The algorithm proceeds point by point and determines its optimal cluster assignment.The method only iterates if some cluster has a point closer to some other cluster's center.Hartigan's method takes into account the motion of the means resulting from the reassignment-that is, it may reassign a point to another cluster, even if it is already assigned to the closest center.
Thanks to such a modification, the unnecessary clusters are efficiently removed [40], usually in the first three or four iterations.In consequence, one needs smaller number of steps in each iteration to find the local minimum.Moreover, Hartigan's method finds essentially better minima (with lower cost function value).In Fig. 2, we present the convergence process of Hartigan's afCEC with the initial number of clusters at k = 10 , which is reduced to k = 5.
The modification also allows processing data streams [33] in which the input is presented as a sequence of items and can be examined in only a few passes (typically just one).
These algorithms have limited memory available for them (much less than the input size) and also limited processing time per item.The intrinsic nature of stream data requires the development of algorithms capable of performing fast and incremental processing of data objects.Therefore, Hartigan's version of afCEC algorithm can be applied in data streams clustering.
The paper is organized as follows.In the next section, related work is presented.In Sect.3, we introduce afCEC algorithm.In Sect.4, we present the Hartigan modification of the method.In particular, we discuss how to update parameters online.In the last section, a comparison between our approach and classical algorithms is made.

Related works
Clustering is the classical problem of dividing a data X ∈ ℝ N into a collection of disjoint groups X 1 , … X k .Several of the most popular clustering methods are based on the k-means approach [1].In the context of the algorithm, there were introduced two basic heuristics for minimizing the cost function: Lloyd's and Hartigan's.The methods became standards in the general clustering theorem.
The first heuristic for k-means (or general clustering methods) is the Lloyd's approach: given some initial clustering, we assign points to the closest one [9,25,26].This scheme is intuitive, and empirical support is favorable: the technique generally seems to find a good solution in a small number of iterations.The alternative heuristic was presented by Hartigan [14,15]: repeatedly pick a point and determine its optimal cluster assignment.The obvious distinction with Lloyd is that the algorithm proceeds point by point.The comparison of the method is presented in [41].Roughly speaking, in the context of k-means, Hartigan's approach converges to the minimum faster and generally find better minima of the cost function.On the other hand, Lloyd's approach is more resistant to outliers.
The basic drawback of k-means algorithm was solved by using density-based techniques, which use expectation maximization (EM) method [27].The Gaussian mixture model (GMM) is probably the most popular [28,29].Thanks to this approach, we can describe clusters by more general shapes like ellipses.
The cross-entropy clustering (CEC) approach [40] joins the clustering advantages of k-means and EM.It turns out that CEC inherits the speed and scalability of k-means, while overcoming the ability of EM to use mixture models.CEC allows an automatic reduction in "unnecessary" clusters, since, contrary to the case of classical k-means and EM, there is a cost of using each cluster.One of the most important properties of CEC, in relation to GMM, is that, similar to k-means, we can use Hartigan's approach.
Since typically data lie around curved structures (manifold hypotheses), algorithms which can approximate curves or manifolds are important.Principal curves and principal surfaces [16,18,22] have been defined as self-consistent smooth curves (or surfaces in ℝ 2 ) which pass through the middle of a d-dimensional probability distribution or data cloud.They give a summary of the data and also serve as an efficient feature extraction tool.
Another method that attempts to solve the problem of fitting nonlinear manifolds is that of self-organizing maps (SOM) [20], or self-organizing feature maps (SOFM) [19].These methods are types of artificial neural networks which are trained using unsupervised learning to produce a lowdimensional (typically two-dimensional) discretized representation of the input space of the training samples, called a map.
Kernel methods provide a powerful way of capturing nonlinear relations.One of the most common, kernel PCA (KCPA) [32], is a nonlinear version of principal component analysis (PCA) [17] that gives an explicit low-dimensional space such that the data variance in the feature space is preserved as much as possible.
The above approaches focus on finding only a single complex manifold.In general, they do not focus on the clustering method.Furthermore, it is difficult to use them for dealing with clustering problems.Kernel methods and self-organizing maps can be used as a preprocessing for classical clustering methods.In such a way, spectral clustering methods were constructed [24].The classical kernel k-means [24] is equivalent to KPCA prior to the conventional k-means algorithm.Spectral clustering is a large family of grouping methods which partition data using eigenvectors of an affinity matrix derived from the data [7,[43][44][45]48].
The active curve axis Gaussian mixture model (Aca-GMM) [47] is an adaptation of the Gaussian mixture model, which uses a nonlinear curved Gaussian probability model in clustering.AcaGMM works well in practice; however, it has major limitations.First of all, the AcaGMM cost function does not necessarily decrease with iterations, which causes problems with the stop condition, see [39].Since the method uses orthogonal projections and arc lengths, it is very hard to use AcaGMM for more complicated curves in higherdimensional spaces.
The active function cross-entropy clustering [39] (afCEC) method (see Fig. 1b), which is based on the cross-entropy clustering (CEC) model, solves all the above limitations.The method has a few advantages in relation to AcaGMM: it enables easy adaptation to clustering of complicated datasets along with a predefined family of functions and does not need external methods to determine the number of clusters, as it automatically reduces the number of groups.
In practice, afCEC gives essentially better results than linear models like GMM or CEC, since we obtain a similar level of the Log-likelihood function by using a smaller number of parameters to describe the model.On the other hand, the results are similar to that of AcaGMM when we restrict the data to two dimensions and use the quadratic function as the baseline.For more detailed comparison between the methods, see [39].
All the above approaches do not have Hartigan's versions.In this article, we present an online afCEC algorithm.In the case of Lloyd's approach, authors use the regression method for each step.In this paper, we present how to apply Hartigan's heuristic for minimizing afCEC cost function.Thanks to this modification, we obtain a method which is able to remove unnecessary clusters very fast and, consequently, we obtain a lower computational complexity.Moreover, we obtain a better minimum (with lower value of the cost function).

AfCEC algorithm
In this section, we briefly describe AfCEC method (for more information we refer to [39]).At the beginning, we introduce a density distribution which was used in AfCEC methodf-adapted Gaussian density.Let us recall that the standard Gaussian density in ℝ d is defined by where m denotes the mean, is the covariance matrix, and ‖v‖ 2 = v T −1 v is the square of the Mahalanobis norm.
In our work, we use a multidimensional Gaussian density in a curvilinear coordinate system which is "spread" along the function f ∶ ℝ d−1 → ℝ (f-adapted Gaussian density).We treat one of the variables separately.In such a case, we consider only those ∈  d (ℝ) (where  d (ℝ) denotes the set of d-dimensional square, symmetrical, and positive define matrices) which have the diagonal block matrix form where  ̂l ∈  d−1 (ℝ) and  l > 0 .For x = [x 1 , … , x d ] T ∈ ℝ d and l ∈ {1, … , d} , we will use the notation Now, we will give a mathematically formal definition of the f-adapted Gaussian function.
given.The f-adapted Gaussian den- sity for  ̂l , l , l ∈ {1, … , d} and m is defined as follows: In the basic form of the CEC algorithm [40], we are looking for the optimal Gaussian function in the family of all d-dimensional Gaussian densities (ℝ d ) .In the case of AfCEC, we describe each cluster by the f-adapted Gaussian function, see Fig. 3. Consequently, we need to find optimal density in the class of all curved Gaussians.For the given f ∶ ℝ d−1 → ℝ , we denote the family of all f-adapted Gauss- ian functions by ( 1) ( In the AfCEC algorithm, we describe clusters by generalized Gaussian distributions from  l [f ] where f is in some class of functions (we can use any class of functions for which the regression procedure works) and l ∈ {1, … , d} .Therefore, we will need one more definition.For the family  ⊂ (ℝ d−1 , ℝ) , we define In the previous considerations, we assumed that one variable was chosen to be dependent.Since, in the case of the -adaptive Gaussian density, all computations are applied in the canonical basis, we can verify all possible dependent variable choices.For the family  ⊂ (ℝ d−1 , ℝ) , we define the family of -adapted Gaussian distributions with all the possible choices of dependent variables by Since our method is based on the CEC approach, we start with a short introduction to the method (for a more detailed explanation we refer the reader to [40]).To apply CEC, we need to introduce the cost function which we want to minimize.In the case of splitting X ⊂ ℝ d into X 1 , … , X k so that we code elements of X i using a function from the family of all Gaussian densities (ℝ d ) , the mean code-length of a randomly chosen element x equals (3) where The formula uses the cross-entropy of a dataset with respect to the family (ℝ d ) .In the case of AfCEC, our goal is to calculate an explicit formula for the cost function in the case of f-adapted Gaussian densities.

Optimization Problem 31 Divide the dataset
If  is a set of functions which are invariant under the operations f → a + f for any a, we have a following theorem.
Theorem 1 Let X ⊂ ℝ d be a dataset, and let a family of functions where  ̂l = cov(X ̂l) and l ∈ {1, … , d}.
We can analyze each cluster separately.For one cluster X ⊂ ℝ d , we estimate the parameters of the model in two steps.First, we consider all of the possible choices of dependent variables and calculate functions f l (corre- sponding to relations x l = f l (x ̂l) ), means m l = mean(X Then we determine the optimal dependent variable j = argmin l∈{1,…,d} {H × (X‖ l [ ])}.Consequently, our data- set is represented by the active function, mean, and covariance matrix where subscript j ∈ {1, … , d} denotes the dependent vari- able in the cluster.The above parameters minimize the cost function of one cluster H × (X‖[ ]).
CEC allows an automatic reduction in "unnecessary" clusters, since, contrary to the case of classical k-means and EM, there is a cost of using each cluster.(The stepby-step view of this process is shown in Fig. 2.) There are ( 5) also several probabilistic approaches which try to estimate the correct number of clusters.For example, [11] uses the generalized distance between Gaussian mixture models with different components number by using the Kullback-Leibler divergence, see [6,21].A similar idea is presented by [46] (Competitive Expectation Maximization) which uses the minimum message length criterion provided by [8].In practice, MDLP can also be directly used in clustering, see [42].However, most of the above-mentioned methods typically proceed through all the consecutive clusters and do not reduce the number of clusters online during the clustering process.
Classical AfCEC algorithm presented in [39] uses Lloyd's method.The alternative heuristic was presented by Hartigan [14,15]: repeatedly pick a point and determine its optimal (from the cost function's point of view) cluster assignment.Observe that in the crucial step in Hartigan's approach we compare the cross-entropy after and before the switch, while the switch removes a given point from one cluster and adds it to the other.It means that to apply efficiently the Hartigan approach in clustering it is essential to update parameters (7) when we add a point to the cluster and downdate parameters (7) when we delete a point from group.In the next section, we present how we can update and downdate all parameters of afCEC online.

Updating the value of the cost function
Recall that for the particular cluster X our goal is to present how to update and downdate meta-parameters: Observe that in the crucial step in Hartigan's approach we compare the cross-entropy after and before the switch.Therefore, it is enough to update/downdate only parameters on which the afCEC cost function depends.Evaluating the cost function for the dataset X ∈ ℝ d involves computing two quantities: the covariance matrix on X d and mean squared error (MSE), respectively, on the d-coordinate along the active axis defined as the mean squared error of the linear least-squares approximation of the data along the active axis.
It should be highlighted that for updating the above parameters we additionally require some other information.In the case of cov(X d) , we need to store the mean(X d) .In such a case, we have a simple formula.Update and downdate procedures are given by the following formulas: where In the case of the second quantity , we have a more complicated situation.Our goal is to update/ downdate the regression function f.There are many types of regression models.In our work, we consider a general one.For a data X ⊂ ℝ d , we use the model where f j are linearly independent functions.In the case of f j (x d) = x j−1 , we obtain a classical polynomial regression.Therefore, our goal is to find a vector α = 1 … m T , which minimizes Directly from the regression theory, we can calculate the vector α as a solution to a system of linear equations.

T h e o r e m 2 L e t
where f i ∶ ℝ d−1 → ℝ are linearly independent functions for which linear regression is considered.Then, the vector α which minimizes the mean squared error satisfies the following linear equation system: Similar to the previous situation, we will store additional elements to be able to update/downdate our parameters.For the data X, we denote the matrix from Eq. ( 14) by A X and the vector from Eq. ( 14) b X .Consequently, Eq. ( 14) can be rewritten in the following form The main idea is to update/downdate parameters A X and b X and solve the linear equation in each iteration to determine the updated α.

T h e o r e m 3 L e t
where f i ∶ ℝ d−1 → ℝ are linearly independent functions for which linear regression is considered.For x, update (x ∉ X) and downdate (x ∈ X) procedures are given by the following formulas: (a) The update procedure: (b) The downdate procedure: Proof Let X and x be given.A simple corollary from Theo- rem 2 is that the vector α which minimizes the mean squared error satisfies the following linear equation system: Now we add/remove x from X. Therefore, by Theorem 2 for X ∪ {x} or X ⧵ {x} , respectively, we obtain □ Thanks to Theorem 3, we can update parameters A X and b X .Then we solve the system of linear equations A X α = b X .Therefore, we obtain α for X ∪ {x} or X ⧵ {x} , respectively.In the last step, we can update and downdate the mean squared error (MSE), respectively, on the d-coordinate by using a new value of A, b, α.
T h e o r e m 4 L e t X ∈ ℝ d b e g i v e n .L e t f ( , where f i ∶ ℝ d−1 → ℝ are linearly independent functions for which linear regression is considered.Then where .

Proof
We have

□
This can be always done, provided that the matrix X or X⧵{x} (depending on whether we add or remove the point x from the dataset X) is non-singular.Having the values of { 1 , … , k } , one can immediately obtain the desired value.

Algorithm
In this section, we present our algorithm.The aim of the Hartigan's method is to find a partition X 1 , … , X n of X, for which the cost function (4) is as close as possible to the minimum, by subsequently reassigning membership of elements from X.
To explain Hartigan's approach more precisely, we need the notion of a group membership function gr ∶ {1, … , n} → {0, … , k}, which describes the member- ship of the ith element, where 0 value is a special symbol which denotes that x i is as yet unassigned.In other words, if gr(i) = l > 0 , then x i is a part of the lth group, and if gr(i) = 0 then x i is unassigned.
In Algorithm 1, we present a pseudo-code of the method.The algorithm starts from an initial clustering, which can be obtained randomly or with the use of the k-means++.In our case, we assume that we have an initial clustering given by cl .(The number of clusters is given by k.)At the begin- ning, the algorithm calculates the initial values of parameters which describe each cluster.

MSE
We want to find such gr ∶ {1, … , n} → {1, … , k} (thus all elements of X are assigned) that E(X 1 , … , X k ; [ ]) is minimal.The basic idea of Hartigan is relatively simple-we repeatedly go over all elements of the partition X = (x i ) n i=1 and apply the following steps: -If the chosen set x i is unassigned, assign it to the first non-empty group; -Reassign x i to that group for which the decrease in cross- entropy is maximal; -Check if no group needs to be removed/unassigned, if this is the case unassign its all elements; until no group membership has been changed.To implement Hartigan's approach, we still have to add a condition regarding when to unassign a given group.For example, in the case of AfCEC clustering in ℝ d , to avoid overfitting we cannot consider clusters which contain less then d + 1 points.In practice while applying Hartigan's approach on discrete data, we usually remove clusters which contain less then five percent of all dataset.
Observe that in the crucial step in Hartigan's approach, we compare the cross-entropy after and before the switch, while the switch removes a given point from one cluster and adds it to the other.It means that to apply the Hartigan approach efficiently in clustering, it is essential to update/ downdate parameters when we add/delete a point from a group by using formulas from Sect. 4.

Experiments
In this section, we present a comparison of the Hartigan version of afCEC with density-based methods: GMM, CEC, and Lloyd's afCEC.It is difficult to compare methods, which use different number of parameters to approximate data.In general, if we use a more complex model, we can fit the data better.Therefore, we use indexes which measure level of fitting and use penalty for using more complicated models.
Hence, there is a trade-off: the better fit, created by making a model more complex by requiring more parameters, must be considered in light of the penalty imposed by adding more parameters.
To compare the results, we use the standard Akaike information criterion (AIC): and Bayesian information criterion (BIC): where k is the number of parameters in the model, n is the number of points, and LL is a maximized value of the loglikelihood function.
Let's analyze the two components of the AIC.The first component, − 2LL, is the value of the likelihood function, which is the probability of obtaining the data given the candidate model.It measures how well the data are fitted by the model.Since the likelihood function's value is multiplied by − 2 , ignoring the second component, the model with the minimum AIC is the one with the highest value of the likelihood function.
However, to this first component we add an adjustment based on the number of estimated parameters.The more parameters, the greater the amount added to the first component, increasing the value for the AIC and penalizing the model.Hence, there is a trade-off: the better fit, created by making a model more complex by requiring more parameters, must be considered in light of the penalty imposed by adding more parameters.This is why the second component of the AIC is thought of in terms of a penalty.
The Bayesian information criterion (BIC) is another model selection criterion based on information theory but set within a Bayesian context.The difference between the BIC and the AIC is the greater penalty imposed for the number of parameters by the former than the latter.
Consequently, we need a number of parameters which are used in each model.In the case of ℝ 2 , afCEC uses two scalars for the mean, three scalars for the covariance matrix, and three scalars for the parabola.It should be emphasized that in afCEC, we need to remember which coordinate is the dependent one.This parameter is discrete, so we do not consider it in our investigation.

The computational times
We compared the computational times between Hartigan version of afCEC and alternative methods: CEC implemented in R package CEC [37,40] and GMM from R package Rmixmod [23].We varied the number of dataset One can observe that in the case of higher dimensions both afCEC methods give slightly worse results since the regression function must be fitted with respect to all possible dependent variables.It should be highlighted that the application of afCEC method in high-dimensional spaces is rather limited.CEC and GMM methods give comparable results for large datasets.
In the case of data with an increasing number of elements, we can observe that afCEC method gives comparable results to the GMM approach.The method can be applied even to reasonably large datasets.We can observe that Lloyd's approach gives slightly better results than Hartigan's algorithm, since we do not have to update parameters in each step.But the use of an online version of the method allows to obtain a better minimum of the cost function and consequently, better clustering, see Tables 1 and 2.

2D dataset
Let us start with a synthetic dataset.At first, we report the results of afCEC, GMM, CEC in the case of simple 2D sets, see the first two examples in Table 1.As we see, for similar values of the log-likelihood function, we have to use less clusters for afCEC than in GMM and CEC.Moreover, Hartigan's approach gives better results than Lloyd's method.
Chinese characters consist of straight-line strokes (horizontal, vertical) and curved strokes (slash, backslash and many types of hooks).GMM has already been employed for analyzing the structure of Chinese characters and has achieved commendable performance [46].However, some lines extracted by GMM may be too short, and it is quite difficult to join these short lines to form semantic strokes due to the ambiguity of joining them together.This problem becomes more serious when analyzing handwritten characters by GMM, and this was the motivation to use afCEC to represent Chinese characters, see Fig. 5.
In the case of the characters 猫 (cat) for similar values of the log-likelihood function, we have to use 25 clusters for Hartigan afCEC and 35 for GMM and CEC.On the other hand, for simpler characters 犬 (dog), 火 (father) , we have to use 6 clusters for Hartigan afCEC and 10 for GMM and CEC, see Table 1.
In general, afCEC method usually obtained clustering with the largest value of MLE function.The cost of using additional parameters is small and, consequently, afCEC gives a better clustering in respect to AIC and BIC criteria, see Fig. 6a.

3D scans of objects
In this subsection, we present how our method works in the case of segmentation of 3D objects.Similarly as before, we report the results of afCEC, GMM, CEC, see Table 2.We show how the log-likelihood, BIC, and AIC functions change when the number of clusters increases.As we can see, for similar values of the log-likelihood function, we have to use less clusters for afCEC than for GMM and CEC.Moreover, we also obtain a better value of BIC and AIC, see the last three examples in Table 2.
The effect of afCEC on 3D objects [2,3] is shown in Fig. 7. Since afCEC is able to cluster data on sub-manifolds of ℝ d , it is able to fit strongly nonlinear structures of 3D scans of objects.Moreover, afCEC method automatically reduces unnecessary clusters which allows to reduce too small components.
Similar to the previous experiments, afCEC method usually obtained clusterings with the largest value of MLE function.The cost of using additional parameters is small, and

Comparison with non-density-based methods
Now we present a comparison between afCEC and classical approaches dedicated to clustering of nonlinear datasets: kkmeans [24] and spectral clustering [31] (see Fig. 8).We also use recent modification of the classical method dedicated to nonlinear data STSC [45], SMMC [43], and SSC [7,44,48].In this subsection, we compare algorithms with respect to Rand and Jaccard indexes, see Fig. 9.
Kernel methods can be used as a preprocessing for classical clustering methods.In such a way, spectral clustering methods were constructed [5,24,31].The classical kernel k-means [24] is equivalent to KPCA prior to the conventional k-means algorithm.Most of kernel methods consist of two steps: an embedding into a feature space and a classical clustering method used on the data transformed to feature    In the case of datasets of dimension higher than three and afCEC approach, due to computational profitability, we used a smaller class of quadratic polynomials of the type instead of the class of all quadratic polynomials This allows us to fit less parameters in each step, which results in a smaller risk of overfitting and helps to effectively cluster higher-dimensional data.
In the case of non-density-based method, we use classical Rand and Jaccard indexes.As we see in Fig. 9 afCEC method gives similar results to other approaches and the Hartigan modification allows to obtain better score.

Data streams
Typical statistical and data mining methods, including clustering, work with "static" datasets, meaning that the complete dataset is available as a whole to perform all necessary computations.However, in recent years more and more applications need to work with data which is not static but is the result of a continuous data generating process which is likely to evolve over time.This type of data is called a data stream, and dealing with data streams has become an increasingly important area of research.
The characteristic of continually arriving data points introduces an important property of data streams, which also poses the great challenge: the size of a data stream is potentially unbounded.This leads to the following requirements for data stream processing algorithms: -Bounded storage The algorithm can only store a very limited amount of data to summarize the data stream; -Single pass The incoming data points cannot be permanently stored and need to be processed at once in the arriving order; -Real-time The algorithm has to process data points on average at least as fast as the data is arriving; -Concept drift The algorithm has to be able to deal with a data generating process which evolves over time (e.g., distributions change or a new structure in the data appears).
In this section, we present a possible application of afCEC method to stream data.We will use the R package stream [12].In our experiments, we use DSD_Benchmark(1) (see Fig. 10a) form stream, which contains two clusters moving in a two-dimensional space.One moves from the top left to the bottom right and the other one moves from the bottom left to the top right.Both clusters overlap when they meet exactly in the center of the data space.Figure 10a shows plots where clusters move over time.Arrows are added to highlight the direction of cluster movement.
Figure 10c shows the Rand index for the four data stream clustering algorithms and afCEC method over the evolving data stream.All algorithms show that separating the two clusters is impossible around position 3000 when the two clusters overlap.It should be highlighted that afCEC method has a problem with reconstructing the model after the merge.The number of clusters was reduced and cannot be reconstructed.It is possible to add a split merge strategy [13] which would allow to refit afCEC model.The second possible strategy is to add an additional dimension with time components.Since afCEC is an affine invariant it does not change clustering structures and allows to keep two clusters without reduction.
In general, afCEC works in the case when a dataset contains curve-type structures.In the second example, we present how the methods work on such data.Similar to the previous examples, we consider two clusters (two curvetype clusters), where the first moves from top left to bottom right, and the other one moves from bottom left to top right.Figure 10b shows plots where the clusters move over time.Arrows are added to highlight the direction of cluster movement.Figure 10d shows the Rand index.As we see, AfCEC is able to almost perfectly recover the original clustering .

Conclusions
In this paper, the Hartigan approach to afCEC method for clustering curved data, which uses generalized Gaussian distributions in curvilinear coordinate systems, was presented.The afCEC method has a strong theoretical background.Moreover, afCEC can be used as a density estimation model.Since afCEC is an implementation of the cross-entropy clustering approach, the method reduces unnecessary clusters online.
In practice, the algorithm gives essentially better results than linear models, like GMM or CEC and the classical Lloyd's approach to afCEC, since we obtain a similar level of the Log-likelihood function by using a smaller number of parameters to describe the model.Moreover, the online version of afCEC method can be use in the case of stream data.
In the future, we want to update our algorithm to allow the use of closed curves.Thanks to such a modification, we will able either to find more complicated shapes in data or to better adapt to the data structure.

Algorithm 1 :
(HARTIGAN-BASED afCEC): input dataset X number of clusters k > 0 initial clustering X1, . . ., Xk family F ⊂ C(R d−1 , R) for regression F-adapted Gaussian distributions family A[F ] cluster reduction parameter ε > 0 define cluster membership function cl : X x → l ∈ {1, . . ., k} such that x ∈ Xl cluster cost function E(Xi) where E(Y ) = p(− ln(p) + H × (Y [F ])) and p = cardY cardX repeat for x ∈ X do for i = 1, . . ., k : x / ∈ Xi do if E(Xi ∪ {x}) + E(X cl(x) \ {x}) < E(Xi) + E(X cl(x) ) then switch x to Xi update cl update/downdate parameters of f -adapted Gaussian distributions in Xi and X cl(x) respectively if cardXi < ε • cardX then delete cluster Xi update cl by attaching elements of Xi to existing clusters end if end if end for end for until no switch for all subsequent elements of X instances and the dimension of the data, see Fig. 4. For this purpose, a simple ball-like set was considered.

Fig. 4
Fig.4 Comparison of computational efficiency between afCEC, CEC, and GMM. a Comparison of computational efficiency between afCEC, CEC, and GMM in the case of data with different dimen- 6b .

Fig. 5
Fig. 5 Effect of Hartigan's version of afCEC clustering in the case of Chinese characters.a Original dataset.b Hartigan's afCEC clustering.c Hartigan's afCEC clustering.d Original dataset.e Hartigan's afCEC clustering.f Hartigan's afCEC clustering

Fig. 6
Fig. 6 Mean values of MLE, BIC, and AIC in the case of 2D and 3D datasets.a Mean values of MLE, BIC, and AIC in the case of 2D datasets.b Mean values of MLE, BIC, and AIC in the case of 3D datasets , spectral methods are typically time-consuming and use large number of parameters.

Table 1
Comparison of afCEC, GMM, CEC, and Lloyd's afCEC in the case of a 2D datasetsThe best values of MLE, BIC and AIC for each experiment is marked with bold font

Table 2
Comparison of afCEC, GMM, CEC, and Lloyd's afCEC in the case of a 3D datasetsThe best values of MLE, BIC and AIC for each experiment is marked with bold font