DESCRIPTION Students: Please note instructions in paper copy of quiz. Save your files often, make sure OMSI fills your entire screen at all times, etc. A question may not fully fit into your OMSI question box, which is not scrollable. You can try adjusting the relative size of the question and answer boxes, but remember that clicking CopyQtoA will copy the entire question box to the answer box. QUESTION (30 pts) Which can accommodate prediction of new users' ratings of old movies? (choose as many as apply.) "Old" and "new" refer to our original matrix A. No covariates used. (i) lm(), and the new user only has rated old movies (ii) lm(), and the new user only has rated new movies (iii) lm(), and the new user has rated both old and new movies (iv) NMF, and the new user only has rated old movies (v) NMF, and the new user only has rated new movies (vi) NMF, and the new user has rated both old and new movies QUESTION -ext .R -run 'Rscript omsi_answer2.R' (35 pts) The code below will run NMF on the InstEval data using recosystem, and then will complete the matrix and evaluate the accuracy (on the same data, no cross-validation). The accuracy measure is proportion of correctly predicted ratings, not MAPE. Use rank 20. gy <- function() { library(lme4) data(InstEval) ie <- InstEval # easier if IDs are 1,2,3,..., and ratings are numeric factorToNumToFactor <- function(f) as.factor(as.numeric(f)) ie$s <- factorToNumToFactor(ie$s) ie$d <- factorToNumToFactor(ie$d) ie$y <- as.numeric(ie$y) library(recosystem) r <- Reco() # training set will be all of ie, but need in recosystem form r$train(ie.trn, ) result <- r$output(out_memory(),out_memory()) # for a given row in ie, find the predicted rating findPred <- function(row) { row <- as.numeric(row) # factors treated as character mode, need nums userID <- row[1] instID <- row[2] round( ) } # get vector of predicted ratings for ie preds <- apply(ie,1,findPred) mean( ) } print(gy()) QUESTION -ext .R -run 'Rscript omsi_answer3.R' (35 pts) The nmf() function below will return W and H for the approximate factorization WH, using the ALS algorithm. It is assumed that the A matrix in the first argument is fully known. The second and third arguments are the initial guesses, and nIters is the number of iterations; A find-H, find-W cycle counts as one iteration. Note: Do not constrain W and H to be nonnegative; this question is really about ALS, not NMF. nmf <- function(a,w0,h0,nIters) { w <- w0; h <- h0 nch <- ncol(h) nrw <- nrow(w) for (iter in 1:nIters) { } list(w=w, h=h) } a <- rbind(2:5,c(4,3,5,1),c(2,2,1,4),1:4) w0 <- matrix(1:8,ncol=2) h0 <- matrix(1:8,nrow=2) print(nmf(a,w0,h0,2))