Description Usage Arguments Details Value Author(s) See Also Examples
View source: R/rescal_Trp_Val.R
calaculate scores from RESCAL factorization for a pairse of subjects and objects indices on one predicate
1 | rescal_SO_Val(R, A, Subj, P, Obj)
|
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 |
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,])
Data frame of four columns: Subj, Predicate, Obj, and val. val column is the score
Abdelmoneim Amer Desouki
rescal
scRescal
rescal_Trp_Val
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))
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.