r - 使用 r 的块模型
问题描述
我正在尝试使用库块模型对一些生物数据进行分类。我得到了最好的数据模型(6 类)。问题是我如何获得每个数据的标签(标签向量)。这是我的代码(垫子是 132*132 数组):
my_model <- BM_poisson("SBM_sym",mat)
my_model$estimate()
which.max(my_model$ICL)
my_model$model_parameters[6]
my_model$plot_obs_pred(6)
谢谢
解决方案
这就是我解决问题的方法:
library("network")
library("ramify")
mynet <- as.network(mat)
my_model <- BM_bernoulli("SBM",mat)
my_model$estimate()
#K ist most probable number of classes
K<-which.max(my_model$ICL)
#argmax of Z is the most probable classmemebership
classmembership <-argmax(my_model$memberships[[K]]$Z)
#set classmembership as attribute for plotting
network::set.vertex.attribute(mynet, "Class", classmembership)
推荐阅读
- c - 使用 malloc 函数制作的数组超出了所需的大小
- jenkins - jenkins-pipeline readJSON - 如何访问嵌套元素
- angular - 未显示 Antd/Angular 工具提示
- c# - 使用 C# 中使用 Activator 创建的 IOptions 实例
- python - 如何通过单击 xpath 从 url 列表中循环并在 Python 中使用 Selenium 提取数据?
- python - 使用带有异常值的 Matplotlib 手动绘制箱线图
- c++ - 为什么模板参数推导因 std::function 回调的可变模板参数而失败?
- python - Django ORM中的反向外键关系
- angular - ionic - sqllite 插入多行
- spring-boot - docker不工作的spring boot教程?