0

我需要你的帮助。所以,这里是这个的代码。数据来自 Facebook 社交连接指数 (SCI),我正在尝试预测区域之间的 SCI。因此,到目前为止,我已经使用 R 中的库 bnlearn 创建了贝叶斯网络模型,并且还从一个特征(总体)中学习了先验概率。我需要帮助绘制校准图、概率分布图、brier 分数图等。但是,我不知道如何继续,因为 bn.pred 有四个级别(因为我对数据使用了离散化间隔(用于将连续变量转换为分类变量))并且无论我试图将它与测试数据进行比较,我遇到一些错误,我也不会去任何地方。我将不胜感激。

这是代码:

# load the relevant libraries
library(bnlearn)
library(compiler)

# load the dataset

net = tabu(train)

bn = bn.fit(net, train)

write.net("C:\\Users\\rukmani\\Downloads\\10.net", bn)



nationprob = sumnations / sumallnations
cpt = coef(bn[["UserLocation"]])
cpt[1:length(EUROPE)] = nationprob
bn[["UserLocation"]] = cpt
cpt = coef(bn[["FriendsLocation"]])
cpt[1:length(EUROPE)] = nationprob
bn[["FriendsLocation"]] = cpt



write.net("smallmod.net", bn)

bn.pred = predict(bn, node = "scaledsci", data = test, prob = TRUE) 
tabl1 = table(bn.pred, test[, "scaledsci"])
mn = plot(mean(bn.pred == test$scaledsci))

数据

4

0 回答 0