【问题标题】:Convex hull in T-SNE plot - RT-SNE 图中的凸包 - R
【发布时间】:2020-07-19 12:59:10
【问题描述】:

基于这个问题How to use ggplot to plot T-SNE clustering 我希望将凸包添加到组中,但它不起作用。有什么原因吗?

代码:

library(ggplot2)
library(Rtsne)
library(Rtsne)

iris_unique <- unique(iris) # Remove duplicates
iris_matrix <- as.matrix(iris_unique[,1:4])
set.seed(42) # Set a seed if you want reproducible results
tsne_out <- Rtsne(iris_matrix) # Run TSNE

tsne_plot <- data.frame(x = tsne_out$Y[,1], y = tsne_out$Y[,2], col = iris_unique$Species)
ggplot(tsne_plot) + geom_point(aes(x=x, y=y, color=col)) + stat_chull(aes(color = iris_unique$Species, fill = iris_unique$Species), geom = "polygon", alpha = 0.1) 

【问题讨论】:

    标签: r ggplot2


    【解决方案1】:

    使用以下代码

    library(ggpubr)
    library(ggplot2)
    library(Rtsne)
    
    iris_unique <- unique(iris) # Remove duplicates
    iris_matrix <- as.matrix(iris_unique[,1:4])
    set.seed(42) # Set a seed if you want reproducible results
    tsne_out <- Rtsne(iris_matrix) # Run TSNE
    
    tsne_plot <- data.frame(x = tsne_out$Y[,1], y = tsne_out$Y[,2], col = iris_unique$Species)
    
    ggplot(tsne_plot) + geom_point(aes(x=x, y=y, color=col)) + 
      stat_chull(aes(x=x, y=y, color = col, fill = col), geom = "polygon", alpha = 0.1) 
    

    【讨论】:

    • 凸包到底是什么?是包围簇的形状吗?
    • 仅此而已。
    猜你喜欢
    • 2017-09-08
    • 1970-01-01
    • 2019-04-17
    • 2020-12-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-04
    • 2018-08-03
    相关资源
    最近更新 更多