hierarchical-clustering

Reordering the high-level clusters from seaborn clustermap results

不想你离开。 提交于 2020-08-25 03:50:50
问题 Is there a way to get from a to b in the following figure with scripting? I am using seaborn.clustermap() to get to a (i.e. the order of the rows are preserved. However, columns order change only at second highest level). I was wondering whether it is possible to use the seaborn.matrix.ClusterGrid that is returned by seaborn.clustermap() , modify it and plot the modified results. b P.S. The reason I am asking this is that the order has a meaning (first comes blue, next green, and finally red)

Reordering the high-level clusters from seaborn clustermap results

拥有回忆 提交于 2020-08-25 03:50:36
问题 Is there a way to get from a to b in the following figure with scripting? I am using seaborn.clustermap() to get to a (i.e. the order of the rows are preserved. However, columns order change only at second highest level). I was wondering whether it is possible to use the seaborn.matrix.ClusterGrid that is returned by seaborn.clustermap() , modify it and plot the modified results. b P.S. The reason I am asking this is that the order has a meaning (first comes blue, next green, and finally red)

Matching dendrogram with cluster number in Python's scipy.cluster.hierarchy

耗尽温柔 提交于 2020-08-21 06:29:41
问题 The following code generates a simple hierarchical cluster dendrogram with 10 leaf nodes: import scipy import scipy.cluster.hierarchy as sch import matplotlib.pylab as plt X = scipy.randn(10,2) d = sch.distance.pdist(X) Z= sch.linkage(d,method='complete') P =sch.dendrogram(Z) plt.show() I generate three flat clusters like so: T = sch.fcluster(Z, 3, 'maxclust') # array([3, 1, 1, 2, 2, 2, 2, 2, 1, 2]) However, I'd like to see the cluster labels 1,2,3 on the dendrogram. It's easy for me to

How to line (cut) a dendrogram at the best K

僤鯓⒐⒋嵵緔 提交于 2020-08-08 05:05:09
问题 How do I draw a line in a dendrogram that corresponds the best K for a given criteria? Like this: Lets suppose that this is my dendrogram, and the best K is 4. data("mtcars") myDend <- as.dendrogram(hclust(dist(mtcars))) plot(myDend) I know that abline function is able to draw lines in graphs similarly to the one showed above. However, I don't know how could I calculate the height, so the function is used as abline(h = myHeight) 回答1: The information that you need to get the heights came with

Hierarchical clustering using cosine distance in R

岁酱吖の 提交于 2020-07-19 11:07:37
问题 I want to do hierarchical clustering by using cosine similarity with the R programming language for corpus of documents, but I got the following error: Error in if (is.na(n) || n > 65536L) stop("size cannot be NA nor exceed 65536") : missing value where TRUE/FALSE needed What should I do? To reproduce it, here's an example: library(tm) doc <- c( "The sky is blue.", "The sun is bright today.", "The sun in the sky is bright.", "We can see the shining sun, the bright sun." ) doc_corpus <- Corpus

estimate a repeated measures random effects model with a nested structure using `plm()`

允我心安 提交于 2020-07-08 20:39:06
问题 Is it possible to estimate a repeated measures random effects model with a nested structure using plm() from the plm package? I know it is possible with lmer() from the lme4 package. However, lmer() rely on a likelihood framework and I am curious to do it with plm() . Here's my minimal working example , inspired by this question. First some required packages and data, # install.packages(c("plm", "lme4", "texreg", "mlmRev"), dependencies = TRUE) data(egsingle, package = "mlmRev") the data-set

estimate a repeated measures random effects model with a nested structure using `plm()`

北战南征 提交于 2020-07-08 20:38:14
问题 Is it possible to estimate a repeated measures random effects model with a nested structure using plm() from the plm package? I know it is possible with lmer() from the lme4 package. However, lmer() rely on a likelihood framework and I am curious to do it with plm() . Here's my minimal working example , inspired by this question. First some required packages and data, # install.packages(c("plm", "lme4", "texreg", "mlmRev"), dependencies = TRUE) data(egsingle, package = "mlmRev") the data-set

estimate a repeated measures random effects model with a nested structure using `plm()`

南楼画角 提交于 2020-07-08 20:38:05
问题 Is it possible to estimate a repeated measures random effects model with a nested structure using plm() from the plm package? I know it is possible with lmer() from the lme4 package. However, lmer() rely on a likelihood framework and I am curious to do it with plm() . Here's my minimal working example , inspired by this question. First some required packages and data, # install.packages(c("plm", "lme4", "texreg", "mlmRev"), dependencies = TRUE) data(egsingle, package = "mlmRev") the data-set