rescal_SO_Val: calaculate scores Subj,Predicate,Obj

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/rescal_Trp_Val.R

Description

calaculate scores from RESCAL factorization for a pairse of subjects and objects indices on one predicate

Usage

1
rescal_SO_Val(R, A, Subj, P, Obj)

Arguments

R

core tensor resulting from RESCAL factorization (r by r by m ).

A

Embedding matrix part resulting from RESCAL factorization.

Subj

integer vector containing indices of Subjects

P

index of predicate (slice in tensor)

Obj

integer vector containing inedices of Objects

Details

calaculate scores from RESCAL factorization for a pairse of subjects and objects indices on one predicate. Subj and Obj parameters must have the same length. rowSums(A[Subj,] %*% R[[p]] * A[Obj,])

Value

Data frame of four columns: Subj, Predicate, Obj, and val. val column is the score

Author(s)

Abdelmoneim Amer Desouki

See Also

rescal scRescal rescal_Trp_Val

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (R, A, Subj, P, Obj) 
{
    if (length(Subj) != length(Obj)) {
        stop("rescal_SO_Val: List of subjects and objects must be of the same length")
    }
    val = rowSums((A[Subj, , drop = FALSE] %*% R[[P]]) * (A[Obj, 
        , drop = FALSE]))
    return(data.frame(Subj, P, Obj, val))
  }

RDFTensor documentation built on Jan. 16, 2021, 5:19 p.m.