# predictTensorBF: Predict Missing Values using the Bayesian tensor... In tensorBF: Bayesian Tensor Factorization

## Description

`predictTensorBF` predicts the missing values in the data `Y` using the learned model `res`.

## Usage

 `1` ```predictTensorBF(Y, res) ```

## Arguments

 `Y` is a 3-mode tensor containing missing values as NA's. See function `tensorBF` for details. `res` the model object returned by the function `tensorBF`.

## Details

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.

## Value

A tensor of the same size as `Y` containing predicted values in place of NA's.

## Examples

 ``` 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)) ```

tensorBF documentation built on May 1, 2019, 8:39 p.m.