FramedClust function (Debnath and Song 2021) finds a frame of consecutive points belonging to a large set of univariate data points to obtain the best clustering. The
frame.size parameter indicates the number of points to be included in each frame. The actual width of a frame is the distance between the smallest and largest data points inside the frame.
Here we illustrate how to run the
FramedClust function and visualize the results to explain what framed clustering is.
Any linear dataset can be used with the
FramedClust function. The input vector
X contains some points from a linear data.
X does not have to be sorted. We will find the best
K=7 clusters among all possible frames containing 50 points (
frame.size = 50).
library(OptCirClust) = rgamma(70, 6) X = 7 K = 50frame.size
Now we demonstrate how to cluster the data using three different algorithms: the recommended fast and optimal
"linear.polylog" algorithm, the brute-force and optimal algorithm by repeatedly calling
"Ckmeans.1d.dp", and the slow and heuristic algorithm by repeatedly calling
# Our recommended method is the fast and optimal linear.polylog: <- FramedClust(X, K, frame.size, method = "linear.polylog") result_linear.polylog # The slow and optimal via repeatedly calling Ckmeans.1d.dp: .1d.dp <- FramedClust(X, K, frame.size, method = "Ckmeans.1d.dp") result_Ckmeans # The slow and heuristic via repeatedly calling kmeans: <- FramedClust(X, K, frame.size, method = "kmeans")result_kmeans
The clustering outcomes obtained from the
FramedClust function can be visualized using the
plot(result_linear.polylog, main = "linear.polylog: optimal\n***Recommended***")
plot(result_Ckmeans.1d.dp, main = "Repeated Ckmeans.1d.dp: quadratic time\nalways optimal")
plot(result_kmeans, main = "Repeated kmeans: heuristic\nnot always optimal")
The points are colored according to their cluster. The black dashed line represents an optimal frame with the minimum sum of squared within-cluster distances. All points outside the frame are colored in gray. The
"kmeans" option of the
FramedClust function does not guarantee an optimal solution, while the other two method options do.