DESCRIPTION Students: Please keep in mind the OMSI rules. Save your files often, make sure OMSI fills your entire screen at all times, etc. Remember that clicking CopyQtoA will copy the entire question box to the answer box. In questions involving code which will PARTIALLY be given to you in the question specs, you may need add new lines. There may not be information given as to where the lines should be inserted. MAKE SURE TO RUN THE CODE IN PROBLEMS THAT INVOLVE CODE! QUESTION -ext .R -run 'Rscript ./omsi_answer1.R' (R code answer, 20 points.) One of the first topics usually covered in a linear algebra course is formulating a system of linear equations in matrix form. For example, 3u + 4v = 18 u - v = -1 is expressed as Ax = y, where A = rbind(c(3,4),c(1,-1)), x is the column vector c(u,v) and y is the column vector c(18,-1). We find the x vector via solve(A) %*% y. But the system may have redundant equations, say 3u + 4v = 18 u - v = -1 4u + 3v = 17 Working by hand, we would simply delete one equation. But programmatically, we can use a generalized inverse to solve this or any other redundant system. Do so for the above example. A <- rbind( ) y <- c( ) print('the solution is:') QUESTION -ext .R -run 'Rscript ./omsi_answer2.R' (R code answer, 40 points) Use softImpute() on the House Voting data, omitting the party column. Use rank 5, and (very important) convert the data to 'Incomplete' class first. Congressperson 3 did not vote on Bill 1. Find the predicted vote (raw estimated value, not rounded to 0 or 1). set.seed(1) library(rectools) library(softImpute) QUESTION -ext .R -run 'Rscript ./omsi_answer3.R' (R code answer, 40 points) Implement the ALS code following (6.46), with the call form als(m,r,nmf=FALSE, w0=matrix(runif(nrow(m)*r),nrow=nrow(m)), eps=0.01*max(abs(m)),maxIters=100) Here ALS will be applied to a matrix m, producing rank-r factors. The matrix m is assumed completely intact, no NAs. If nmf is TRUE, use Nonnegative Matrix Factorization, by replacing any negative values in the factors at each iteration. w0 is the initial guess for the matrix w. Iteration will proceed until the change in Frobenius norm between consecutive w %*% h values is less than eps, but will stop if the number of iterations reaches maxIters. library(MASS) als <- function(m,r,nmf=FALSE, w0=matrix(runif(nrow(m)*r),nrow=nrow(m)), eps=0.01*max(abs(m)),maxIters=100) { w <- w0 h <- matrix(rep(0,r*(ncol(m))),nrow=r) for (iter in 1:maxIters) { for (j in 1:ncol(m)) { h[,j] <- if (nmf) } for (i in 1:nrow(m)) { w[i,] <- if (nmf) } if ( ) break if (iter == maxIters) warning( ) } list(w=w,h=h,prd=w %*% h) } set.seed(999) m <- matrix(sample(1:100,48),nrow=6) res <- als(m,3)