RDFTensor (version 1.3)

CP_R01: inverse of real-number-CP-decompositions to Binary

Description

gets the best reconstruction of a CP-factorization by trying different thresholds on the result. If the size of the tensor is too big sampling is done to get estimates of TP, FP.

Usage

CP_R01(X, P, 
    pthr = c(1e-06,1e-04,0.001,0.01,0.05,0.1,0.2,0.3,0.4,0.5,0.55,0.6, 0.65, 0.7, 0.8),
    cntNnz = 200, startSize = 1e+07)

Arguments

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

cntNnz

If |X| is the number of non-zeros in data X, the sampled locations will be cntNnz*|X| of 0s.

startSize

if size of tensor < startSize all values are calculated, default 1e7.

Value

A LIST containing the TP, FP, FN and threshold value also the result of best threshold

See Also

cp_apr serial_parCube rescal rescal_01 cp_nmu

Examples

Run this code
# NOT RUN {
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_R01(X,P1[[1]])
# }

Run the code above in your browser using DataCamp Workspace