# NOT RUN {
<!-- %~~ simple examples of the most important functions ~~ -->
# }
# NOT RUN {
data(DBLP)
X=DBLP
r=7
Xb=X==1#Convert to boolean
tempX=as(X,'TsparseMatrix')
stats=NULL
for(tP in c(0.2,0.3,0.4,0.5,0.6,0.7,0.8,1)){
Res=topFiberM(Xb,r=r,tP=tP,SR=100,verbose=1)
X_=Res$A %*% Res$B
X_=as(X_,'TsparseMatrix')
#Calculate metrics
li=tempX@i[tempX@x==1]+1
lj=tempX@j[tempX@x==1]+1
tp=sum(X_[cbind(li,lj)]>0)
fn=sum(X)-tp#sum(!X_[cbind(li,lj)])
fp=sum(X_@x>0)-tp
cv=1-(fp+fn)/(tp+fn)
stats=rbind(stats,cbind(tP,tp,fn,fp,cv,P=tp*1.0/(tp+fp),R=tp*1.0/(tp+fn)))
}
plot(stats[,'tP'],stats[,'R'],type='b',col='red',lwd=2,
main=sprintf('topFiberM, dataset: %s,
#Known facts:%d','DBLP',sum(X)),ylab="",xlab='tP',
xlim=c(0,1),ylim=c(0,1))
HM=apply(stats,1,function(x){2/(1/x['P']+1/x['R'])})
points(stats[,'tP'],stats[,'P'],col='blue',lwd=2,type='b')
points(stats[,'tP'],HM,col='green',lwd=2,type='b')
grid(nx=10, lty = "dotted", lwd = 2)
legend(legend=c('Recall','Precision','Harmonic mean'),col=c('red','blue','green'),
x=0.6,y=0.2,pch=1,cex=0.75,lwd=2)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab