# reconstructTensorBF: Reconstruct the data based on posterior samples In tensorBF: Bayesian Tensor Factorization

## Description

`reconstructTensorBF` returns the reconstruction of the data based on posterior samples of a given run. The function reconstructs the tensor for each posterior sample and then computes the expected value. The reconstruction is returned in the un-normalized space if `res\$pre` contains appropriate preprocessing information.

## Usage

 `1` ```reconstructTensorBF(res) ```

## Arguments

 `res` The model object from function `tensorBF`.

## Value

The reconstructed data, a tensor of the size equivalent to the data on which the model was run.

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14``` ```#Data generation K <- 3 X <- matrix(rnorm(20*K),20,K) W <- matrix(rnorm(30*K),30,K) U <- matrix(rnorm(3*K),3,K) Y = 0 for(k in 1:K) Y <- Y + outer(outer(X[,k],W[,k]),U[,k]) Y <- Y + array(rnorm(20*30*3,0,0.25),dim=c(20,30,3)) #Run the method with default options and reconstruct the model's representation of the tensor ## Not run: res <- tensorBF(Y) ## Not run: recon = reconstructTensorBF(res) ## Not run: inds = sample(prod(dim(Y)),100) ## Not run: plot(Y[inds],recon[inds],xlab="obs",ylab="recon",main=round(cor(Y[inds],recon[inds]),2)) ```

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