我有由 263 个用户组成的数据集。它具有以下数据帧结构:
userID bookmarkID tagID value
1 52 101 1
1 114 154 1
2 127 14 1
4 114 4 1
对于每个用户,我通过以下等式计算表示频率的变量的值:count() /(书签 ID 的数量 * tagID 的数量)。我得到了这些值:从 1 到 265 的数字只是用户 ID,用户是未订购。
1 2 3 4 5 6
0.0003716331 0.0005655286 0.0001777376 0.0003070012 0.0019389552 0.0002746853
...
...
259 260 261 262 263 264
0.0003393172 0.0006463184 0.0002100535 0.0002100535 0.0001777376 0.0004685808
265
0.0001777376
使用以下 R 代码:
#each user: number of tensor elements which >0 / (num of tags* number of items)
d.file <-
"E:/My_Projects/Bitbucket/TylerRecommender/src/test/resources/DAI_LAbor/p-core of level 12/dataFilePathBeforeTensorDecompositionForTraining80percent.txt"
df<-read.table(d.file,sep="\t",header=T)
itemsize<-length(unique(df$bookmarkID))
tagsize<-length(unique(df$tagID))
itemtagmatrixsize<-itemsize*tagsize
userid.bag<-df$userID
user.tas.count<-table(userid.bag)
dens.tas<-density(user.tas.count/itemtagmatrixsize)
plot(dens.tas, col="red")
d.file2 <-
"E:/My_Projects/Bitbucket/TylerRecommender/src/test/resources/DAI_LAbor/p-core of level 12/~sample_tensor_afterDecomposition_Condensed.example.txt"
df2<-read.table(d.file2,sep="\t",header=T)
lines(density(table(df2$userID)/itemtagmatrixsize), col="blue")
现在我的问题是如何绘制图表来最好地描述用户的频率分布?
我在 R 中使用核密度估计函数 density() 来绘制频率值的概率分布。(这符合我的目的吗?)
但是,我有另一个数据集,它的频率值比下图中的前一个(蓝色)高得多,其中红线与前一个数据集相关:
但是第一个数据集的红线变得完全平坦,这毫无意义。这是为什么?是因为默认选择的带宽吗?是否可以将它们绘制在同一张图中并使它们看起来正常?谢谢!