impute | R Documentation |
These functions produce predictions from the low-rank solution of
softImpute
impute(object, i, j, unscale = TRUE)
object |
an svd object with components u, d and v |
i |
vector of row indices for the locations to be predicted |
j |
vector of column indices for the locations to be predicted |
unscale |
if |
impute
returns a vector of predictions, using the reconstructed
low-rank matrix representation represented by object
. It is used by
complete, which returns a complete matrix with all the missing values
imputed.
Either a vector of predictions or a complete matrix. WARNING: if
x
has large dimensions, the matrix returned by complete
might
be too large.
Trevor Hastie
softImpute
, biScale
and Incomplete
set.seed(101)
n=200
p=100
J=50
np=n*p
missfrac=0.3
x=matrix(rnorm(n*J),n,J)%*%matrix(rnorm(J*p),J,p)+matrix(rnorm(np),n,p)/5
ix=seq(np)
imiss=sample(ix,np*missfrac,replace=FALSE)
xna=x
xna[imiss]=NA
fit1=softImpute(xna,rank=50,lambda=30)
complete(xna,fit1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.