Description Usage Arguments Value Author(s) References See Also Examples
applies different thresholds to get a number of triples from A and R (result of RESCAL) decomposition as scale_fact*the_number_of_triples_in_original_tensor.
1 | rescal_01(X, A, R, scale_fact = 1)
|
X |
is a sparse tensor as set of sparse matrices, one for every relation (predicate). (a LIST of SparseMatrix ) |
A |
the A matrix returned by RESCAL factorization |
R |
the R LIST returned by RESCAL factorization |
scale_fact |
scale of the number of triples to be considered in the result. When it is 1 then a threshold will be taken to get the same number of triples in each slice as the original tensor. |
a LIST
X_ |
The reconstructed tensor as a set of frontal slices. |
tp |
the number of true positives |
fp |
the number of false positives |
fn |
the number of false negatives |
sr |
the details of each slice i.e the number of tp, fn, fp, etc |
Abdelmoneim Amer Desouki
-Maximilian Nickel, Volker Tresp, Hans-Peter-Kriegel, "A Three-Way Model for Collective Learning on Multi-Relational Data", ICML 2011, Bellevue, WA, USA
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | X1=matrix(c(1,0,0,0,0, 0,1,0,0,0, 0,0,1,1,0, 0,0,0,0,1, 1,0,0,0,0),byrow=TRUE,nrow=5,ncol=5)
X2=matrix(c(0,1,0,1,1, 1,0,0,1,0, 0,1,0,1,1, 0,0,0,0,1, 0,0,1,0,0),byrow=TRUE,nrow=5,ncol=5)
X2_=matrix(c(0,1,0,1,1, 1,0,0,1,0, 0,0,0,0,0, 0,0,0,0,1, 0,0,1,0,0),byrow=TRUE,nrow=5,ncol=5)
X=list(t(X1),t(X2),t(X2_))
N=nrow(X1)
Xs=list()
for(s in 1:length(X)){
aa=which(X[[s]]==1,arr.ind=TRUE)
Xs[[s]]=Matrix::sparseMatrix(x=rep(1,nrow(aa)),i=aa[,1],j=aa[,2],dims=c(N,N))
}
print(Xs)
rf=rescal(Xs,2)
A=rf$A
R=rf$R
tmp=rescal_01(Xs,A,R,scale_fact=1.5)#generate 1.5*original number of triples
print(sprintf('Precision:%.4f, Recall:%.4f',tmp$tp/(tmp$tp+tmp$fp),tmp$tp/(tmp$tp+tmp$fn)))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.