朱莉娅词典的UMAP
我给了一个词典,上面有键(ID)和值。
> Dict{Int64, Vector{Float64}} with 122 entries:
3828 => [1, 2, 3, 4...
2672 => [6,7,5,8...
...
现在,我需要对其进行UMAP。我的代码是
embedding = umap(mat, 2; n_neighbors=15, min_dist=0.001, n_epochs=200)
println(size(embedding))
Plots.scatter(embedding[1,:],embedding[2,:])
垫子是矩阵,
1, 2, 3, 4
6, 7, 5, 8
....
所以我得到了嵌入式矩阵和UMAP图。但是在图中,所有点都是相同的颜色,没有标签。我该怎么做,以便可以使用标签(字典中的键)获得积分?
I'm given a dictionary with keys(ids) and values.
> Dict{Int64, Vector{Float64}} with 122 entries:
3828 => [1, 2, 3, 4...
2672 => [6,7,5,8...
...
Now I need to apply umap on it. I have the code that
embedding = umap(mat, 2; n_neighbors=15, min_dist=0.001, n_epochs=200)
println(size(embedding))
Plots.scatter(embedding[1,:],embedding[2,:])
Here mat is the matrix
1, 2, 3, 4
6, 7, 5, 8
....
So I got the embedding matrix and the umap plot. But in the plot all points are same color and no labels. How do I do so that I can get points with labels(keys in the dictionary)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看umap.jl,输入矩阵应具有形状(n_features x n_samples)。如果您的字典中的每个条目都是示例,并且我正在正确解释您的矩阵符号,则看来您已经反转了。
您应该能够将字典的键作为注释添加到图中(可能带有可选的每个坐标的额外偏移):
最后,我不确定您实际上想映射到标记颜色的颜色哪些变量在散点图中。如果是钥匙的整数值,则应像上面一样将其传递给散点功能,除非不将它们变成字符串。
Looking at UMAP.jl, the input matrix should have the shape (n_features x n_samples). If each entry in your dictionary is a sample and I’m interpreting your matrix notation correctly, it appears you have this reversed.
You should be able to add the keys of the dictionary as annotations to the plot as follows (potentially with an optional additional offset to each coordinate):
Finally, I’m not sure what variable you actually want to map to the color of the markers in the scatterplot. If it’s the integer value of the keys you should pass this to the scatter function just like above except without turning them into strings.