Description Usage Arguments Value Author(s) See Also Examples
transforms CP tensor decomposition generated by real-number methods (like nmu) to Binary by trying different threshold values.
1 2 |
X |
the original tensor as sptensor list(subs,vals,size,nnz) |
P |
a LIST containing the CP transformation |
pthr |
list of threshold values to be tried |
testAll |
a flag to try all threshold values or stop after having a zero in fp or tp |
If it is a LIST, use
Res |
the tp, fn, fp result of each threshold value. |
bestSol |
best solution in terms of minimum error (fn+fp) |
Abdelmoneim Amer Desouki
cp_apr
serial_parCube
rescal
rescal_01
cp_nmu
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | trp=rbind(
cbind('Alex', 'loves', 'Don'),
cbind('Alex', 'loves', 'Elly'),
cbind('Alex', 'hates', 'Bob'),
cbind('Don', 'loves', 'Alex'),
cbind('Don', 'hates', 'Chris'),
cbind('Chris', 'hates', 'Bob'),
cbind('Bob', 'hates', 'Chris'),
cbind('Elly', 'hates', 'Chris'),
cbind('Elly', 'hates', 'Bob'),
cbind('Elly', 'loves', 'Alex')
)
######
# form tensor as a set of frontal slices (Predicate mode)
tnsr=getTensor(trp)
subs=getTnsrijk(tnsr$X)
X=list(subs=subs,vals=rep(1,nrow(subs)),size=c(5,2,5))
normX=sqrt(sum(X$vals))
set.seed(123)
# NMU decomposition with rank 2
P1=cp_nmu(X,2)
res=CP_01(X,P1[[1]])
Fac=res$sol$u # The factorization
# TP,FP,FN
print(sprintf("TP=%d, FP=%d, FN=%d, Threshold=%f",res$sol$TP,res$sol$FP,res$sol$FN,res$sol$thr))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.