聚类坐标图 Visualitzation/Analysis
Coordinate Plot for Clustering Visualitzation/Analysis
我有一个包含 8 列的数据集(已经缩放):
- 第一列表示每个观察所属的分配集群,
- 和 7 个因变量(每个都在不同的列中)。
我想通过 R 中的坐标图开发聚类可视化,就像以下博客 (http://blog.datascienceheroes.com/short-lesson-on-cluster-analysis/) 中所示。
谁能帮我解决这个问题?
多种选择。你可以做
library(GGally)
ggparcoord(aggregate(mtcars, list(as.factor(cutree(hclust(dist(mtcars)), k = 4))), mean), columns=-1, groupColumn=1)
或
library(parcoords)
parcoords(
aggregate(mtcars, list(cutree(hclust(dist(mtcars)), k = 4)), mean),
color = list( colorScale = htmlwidgets::JS('d3.scale.category10()'), colorBy = "Group.1")
)
parcoords(
transform(mtcars, cluster = cutree(hclust(dist(mtcars)), k = 4)),
color = list( colorScale = htmlwidgets::JS('d3.scale.category10()'), colorBy = "cluster")
)
您拥有所需函数的代码(plot_clus_coord
)here.
我有一个包含 8 列的数据集(已经缩放):
- 第一列表示每个观察所属的分配集群,
- 和 7 个因变量(每个都在不同的列中)。
我想通过 R 中的坐标图开发聚类可视化,就像以下博客 (http://blog.datascienceheroes.com/short-lesson-on-cluster-analysis/) 中所示。
谁能帮我解决这个问题?
多种选择。你可以做
library(GGally)
ggparcoord(aggregate(mtcars, list(as.factor(cutree(hclust(dist(mtcars)), k = 4))), mean), columns=-1, groupColumn=1)
或
library(parcoords)
parcoords(
aggregate(mtcars, list(cutree(hclust(dist(mtcars)), k = 4)), mean),
color = list( colorScale = htmlwidgets::JS('d3.scale.category10()'), colorBy = "Group.1")
)
parcoords(
transform(mtcars, cluster = cutree(hclust(dist(mtcars)), k = 4)),
color = list( colorScale = htmlwidgets::JS('d3.scale.category10()'), colorBy = "cluster")
)
您拥有所需函数的代码(plot_clus_coord
)here.