Learn R Programming

softImpute (version 1.4)

complete: make predictions from an svd object

Description

These functions produce predictions from the low-rank solution of softImpute

Usage

complete(x, object, unscale = TRUE)
impute(object, i, j, unscale = TRUE)

Arguments

x

a matrix with NAs or a matrix of class "Incomplete".

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 object has biScale attributes, and unscale=TRUE, the imputations reversed the centering and scaling on the predictions.

Value

Either a vector of predictions or a complete matrix. WARNING: if x has large dimensions, the matrix returned by complete might be too large.

Details

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.

See Also

softImpute, biScale and Incomplete

Examples

Run this code
# NOT RUN {
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)
# }

Run the code above in your browser using DataLab