Description Usage Arguments Value Author(s) References Examples
Use the l2 descent problem with general weights to solve the weighted l1 problem, separately for each dimension. If the multicore package is installed each dimension will be processed on a separate core. This is useful since the path algorithm can't be used for general weights, since it only is proven to find the optimal solutions for the identity weights.
1 2 | clusterpath.l1.general(x, join.thresh = NULL, verbose = 0, gamma = 0,
...)
|
x |
Data matrix to cluster. |
join.thresh |
Threshold for fusion. If NULL take a small fraction of the nonzero differences found in the original points x. Passed to clusterpath.l2.general. |
verbose |
Passed to clusterpath.l2.general. |
gamma |
Used for calculating weights using \exp(-γ ||x_i-x_j||^2). |
... |
passed to clusterpath.l2.general. |
Data frame of optimal solutions, with 1 row for each α_i for each lambda.
Toby Dylan Hocking
Hocking, Joulin, Bach, Vert ICML 2011.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | set.seed(7)
sim <- gendata(D=2)
## compare with path algorithm
path <- clusterpath.l1.id(sim$mat)
bpts <- castbreakpoints(path)
p <- plot2d(bpts)
descent.pts <- clusterpath.l1.general(sim$mat)
p+geom_point(aes(alpha.1,alpha.2,size=lambda/max(lambda)),data=descent.pts)
desc <- melt(descent.pts[,1:4],measure=c("alpha.1","alpha.2"))
if(require(latticeExtra)){
plot(path)+
xyplot(value~lambda|variable,desc,groups=row)
}
library(ggplot2)
## compare with cvx
if(cvxmod.available()){
gamma <- 0.1
descent.weights <- clusterpath.l1.general(sim$mat,gamma=gamma,lambda=0.001)
lvals <- c(seq(min(descent.weights$lambda),0.02,l=4),
seq(0.02,max(descent.weights$lambda),l=4))
cvx <- cvxmod.cluster(sim$mat,lvals,norm=1,gamma=gamma)
both <- rbind(descent.weights,cvx)
molt <- melt(both,measure=c("alpha.1","alpha.2"))
ggplot(molt,aes(log(lambda+1),value,colour=solver))+
geom_point(aes(shape=solver))+
facet_grid(variable~.,scales="free")
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.