Description Usage Arguments Details Value Examples
predictTensorBF
predicts the missing values in the data Y
using the learned model res
.
1 | predictTensorBF(Y, res)
|
Y |
is a 3-mode tensor containing missing values as NA's. See function |
res |
the model object returned by the function |
If the original data Y
contained missing values (NA's),
this function predicts them using the model. The predictions are
returned in the un-normalized space if res$pre
contains appropriate
preprocessing information.
A tensor of the same size as Y
containing predicted values in place of NA's.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #Data generation
## Not run: K <- 2
## Not run: X <- matrix(rnorm(20*K),20,K)
## Not run: W <- matrix(rnorm(30*K),30,K)
## Not run: U <- matrix(rnorm(3*K),3,K)
## Not run: Y = 0
## Not run: for(k in 1:K) Y <- Y + outer(outer(X[,k],W[,k]),U[,k])
## Not run: Y <- Y + array(rnorm(20*30*3,0,0.25),dim=c(20,30,3))
#insert missing values
## Not run: m.inds = sample(prod(dim(Y)),100)
## Not run: Yobs = Y[m.inds]
## Not run: Y[m.inds] = NA
#Run the method with default options and predict missing values
## Not run: res <- tensorBF(Y)
## Not run: pred = predictTensorBF(Y=Y,res=res)
## Not run: plot(Yobs,pred[m.inds],xlab="obs",ylab="pred",main=round(cor(Yobs,pred[m.inds]),2))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.