View source: R/convex_clusterpath.R
convex_clusterpath  R Documentation 
Minimizes the convex clustering loss function for a given set of values for lambda.
convex_clusterpath(
X,
W,
lambdas,
tau = 0.001,
center = TRUE,
scale = TRUE,
eps_conv = 1e06,
burnin_iter = 25,
max_iter_conv = 5000,
save_clusterpath = TRUE,
target_losses = NULL,
save_losses = FALSE,
save_convergence_norms = FALSE
)
X 
An 
W 
A 
lambdas 
A vector containing the values for the penalty parameter. 
tau 
Parameter to compute the threshold to fuse clusters. Default is 0.001. 
center 
If 
scale 
If 
eps_conv 
Parameter for determining convergence of the minimization. Default is 1e6. 
burnin_iter 
Number of updates of the loss function that are done without step doubling. Default is 25. 
max_iter_conv 
Maximum number of iterations for minimizing the loss function. Default is 5000. 
save_clusterpath 
If 
target_losses 
The values of the loss function that are used to
determine convergence of the algorithm (tested as: loss  target <=

save_losses 
If 
save_convergence_norms 
If 
A cvxclust
object containing the following
info 
A dataframe containing for each value for lambda: the number of different clusters, and the value of the loss function at the minimum. 
merge 
The merge table containing the order at which the
observations in 
height 
The value for lambda at which each reduction in the number of clusters occurs. 
order 
The order of the observations in 
elapsed_time 
The number of seconds that elapsed while
running the code. Note that this does not include the time required for
input checking and possibly scaling and centering 
coordinates 
The clusterpath coordinates. Only part of the
output in case that 
lambdas 
The values for lambda for which a clustering was found. 
eps_fusions 
The threshold for cluster fusions that was used by the algorithm. 
num_clusters 
The different numbers of clusters that have been found. 
n 
The number of observations in 
losses 
Optional: if 
convergence_norms 
Optional: if

convex_clustering, sparse_weights
# Load data
data(two_half_moons)
data = as.matrix(two_half_moons)
X = data[, 3]
y = data[, 3]
# Get sparse weights in dictionary of keys format with k = 5 and phi = 8
W = sparse_weights(X, 5, 8.0)
# Set a sequence for lambda
lambdas = seq(0, 2400, 1)
# Compute clusterpath
res = convex_clusterpath(X, W, lambdas)
# Get cluster labels for two clusters
labels = clusters(res, 2)
# Plot the clusterpath with colors based on the cluster labels
plot(res, col = labels)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.