作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这是使用 IRIS 数据的 t-SNE 代码:
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
# Show the objects in the 2D tsne representation
plot(tsne_out$Y,col=iris_unique$Species)
最佳答案
我认为最简单/最干净 ggplot
方法是将您需要的所有信息存储在 data.frame
中然后绘制它。从上面粘贴的代码中,这应该有效:
library(ggplot2)
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))
plot
功能是:
plot(tsne_out$Y,col=iris_unique$Species)
关于r - 如何使用 ggplot 绘制 T-SNE 聚类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44837536/
我是一名优秀的程序员,十分优秀!