Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CS 7641 CSE/ISYE 6740 Homework 3 Le Song Deadline: 11/07 Mon, 11:55pm Submit your answers as an electronic copy on T-square. No unapproved extension of

CS 7641 CSE/ISYE 6740 Homework 3 Le Song Deadline: 11/07 Mon, 11:55pm Submit your answers as an electronic copy on T-square. No unapproved extension of deadline is allowed. Zero credit will be assigned for late submissions. Email request for late submission may not be replied. For typed answers with LaTeX (recommended) or word processors, extra credits will be given. If you handwrite, try to be clear as much as possible. No credit may be given to unreadable handwriting. Explicitly mention your collaborators if any. Recommended reading: PRML1 Section 3.1, 3.2 1 Linear Regression [30 pts] In class, we derived a closed form solution (normal equation) for linear regression problem: = (X T X)1 X T Y . A probabilistic interpretation of linear regression tells us that we are relying on an assumption that each data point is actually sampled from a linear hyperplane, with some noise. The noise follows a zero-mean Gaussian distribution with constant variance. Specifically, Y i = T X i + \u000fi (1) where \u000fi N (0, 2 I), Rd , and {X i , Y i } is the i-th data point. In other words, we are assuming that each every point is independent to each other and that every data point has same variance. Note (a) Using the normal equation, and the model (Eqn. 1), derive the expectation E[]. that here X is fixed, and only Y is random, i.e. \"fixed design\" as in statistics. [6 pts] [6 pts] (b) Similarly, derive the variance Var[]. (c) Under the white noise assumption above, someone claims that follows Gaussian distribution with mean and variance in (a) and (b), respectively. Do you agree with this claim? Why or why not? [8 pts] (d) Weighted linear regression Suppose we keep the independence assumption but remove the same variance assumption. In other words, data points would be still sampled independently, but now they may have different variance i . Thus, the covariance matrix of Y would be still diagonal, but with different values: 2 1 0 . . . 0 0 22 . . . 0 = . (2) .. .. . .. .. . . . 0 1 Christopher 0 ... n2 M. Bishop, Pattern Recognition and Machine Learning, 2006, Springer. 1 Derive the estimator (similar to the normal equations) for this problem using matrix-vector notations with . [10 pts] 2 Ridge Regression [15 pts] For linear regression, it is often assumed that y = > x + \u000f where , x Rm by absorbing the constant term, and \u000f N (0, 2 ) is a Gaussian random variable. Given n i.i.d samples (x1 , y 1 ), ..., (xn , y n ), we define y = (y 1 , ..., y n )> and X = (x1 , ..., xn )> . Thus, we have y N (X, 2 I). Show that the ridge regression estimate is the mean of the posterior distribution under a Gaussian prior N (0, 2 I). Find the explicit relation between the regularization parameter in the ridge regression estimate of the parameter , and the variances 2 , 2 . 3 3.1 Bayes Classifier Bayes Classifier With General Loss Function In class, we talked about the popular 0-1 loss function in which L(a, b) = 1 for a 6= b and 0 otherwise, which means all wrong predictions cause equal loss. Yet, in many other cases including cancer detection, the asymmetric loss is often preferred (misdiagnosing cancer as no-cancer is much worse). In this problem, we assume to have such an asymmetric loss function where L(a, a) = L(b, b) = 0 and L(a, b) = p, L(b, a) = q, p 6= q. Write down the the Bayes classifier f : X Y for binary classification Y {1, +1}. Simplify the classification rule as much as you can. [20 pts] 3.2 Gaussian Class Conditional distribution (a) Suppose the class conditional distribution is a Gaussian. Based on the general loss function in problem 3.1, write the Bayes classifier as f (X) = sign(h(X)) and simplify h as much as possible. What is the geometric shape of the decision boundary? [10 pts] (b) Repeat (a) but assume the two Gaussians have identical covariance matrices. What is the geometric shape of the decision boundary? [10 pts] (c) Repeat (a) but assume now that the two Gaussians have covariance matrix which is equal to the identity matrix. What is the geometric shape of the decision boundary? [10 pts] 4 Logistic Regression Logistic regression is named after the log-odds of success (the logit of the probability) defined as below: \u0012 ln P [Y = 1|X = x] P [Y = 0|X = x] 2 \u0013 where P [Y = 1|X = x] = exp(w0 + wT x) 1 + exp(w0 + wT x) (a) Show that log-odds of success is a linear function of X. [6 pts] (b) Show that the logistic loss L(z) = log (1 + exp(z)) is a convex function. [9 pts] 5 Programming: Recommendation System [40 pts] Personalized recommendation systems are used in a wide variety of applications such as electronic commerce, social networks, web search, and more. Machine learning techniques play a key role to extract individual preference over items. In this assignment, we explore this popular business application of machine learning, by implementing a simple matrix-factorization-based recommender using gradient descent. Suppose you are an employee in Netflix. You are given a set of ratings (from one star to five stars) from users on many movies they have seen. Using this information, your job is implementing a personalized rating predictor for a given user on unseen movies. That is, a rating predictor can be seen as a function f : U I R, where U and I are the set of users and items, respectively. Typically the range of this function is restricted to between 1 and 5 (stars), which is the the allowed range of the input. Now, let's think about the data representation. Suppose we have m users and n items, and a rating given by a user on a movie. We can represent this information as a form of matrix, namely rating matrix M . Suppose rows of M represent users, while columns do movies. Then, the size of matrix will be m n. Each cell of the matrix may contain a rating on a movie by a user. In M15,47 , for example, it may contain a rating on the item 47 by user 15. If he gave 4 stars, M15,47 = 4. However, as it is almost impossible for everyone to watch large portion of movies in the market, this rating matrix should be very sparse in nature. Typically, only 1% of the cells in the rating matrix are observed in average. All other 99% are missing values, which means the corresponding user did not see (or just did not provide the rating for) the corresponding movie. Our goal with the rating predictor is estimating those missing values, reflecting the user's preference learned from available ratings. Our approach for this problem is matrix factorization. Specifically, we assume that the rating matrix M is a low-rank matrix. Intuitively, this reflects our assumption that there is only a small number of factors (e.g, genre, director, main actor/actress, released year, etc.) that determine like or dislike. Let's define r as the number of factors. Then, we learn a user profile U Rmr and an item profile V Rnr . (Recall that m and n are the number of users and items, respectively.) We want to approximate a rating by an inner product of two length r vectors, one representing user profile and the other item profile. Mathematically, a rating by user u on movie i is approximated by Mu,i r X Uu,k Vi,k . (3) k=1 We want to fit each element of U and V by minimizing squared reconstruction error over all training data points. That is, the objective function we minimize is given by E(U, V ) = X (Mu,i UuT Vi )2 = (u,i)M X (u,i)M 3 (Mu,i r X k=1 Uu,k Vi,k )2 (4) where Uu is the uth row of U and Vi is the ith row of V . We observe that this looks very similar to the linear regression. Recall that we minimize in linear regression: E() = m m r X X X (Y i T xi )2 = (Y i k xik )2 i=1 i=1 (5) k=1 where m is the number of training data points. Let's compare (4) and (5). Mu,i in (4) corresponds to Y i in (5), in that both are the observed labels. UuT Vi in (4) corresponds to T xi in (5), in that both are our estimation with our model. The only difference is that both U and V are the parameters to be learned in (4), while only is learned in (5). This is where we personalize our estimation: with linear regression, we apply the same to any input xi , but with matrix factorization, a different profile Uu are applied depending on who is the user u. As U and V are interrelated in (4), there is no closed form solution, unlike linear regression case. Thus, we need to use gradient descent: Uv,k Uv,k E(U, V ) , Uv,k Vj,k Vj,k E(U, V ) , Vj,k (6) where is a hyper-parameter deciding the update rate. It would be straightforward to take partial derivatives of E(U, V ) in (4) with respect to each element Uv,k and Vj,k . Then, we update each element of U and V using the gradient descent formula in (6). (a) Derive the update formula in (6) by solving the partial derivatives. [10 pts] (b) To avoid overfitting, we usually add regularization terms, which penalize for large values in U and V . Redo part (a) using the regularized objective function below. [5 pts] E(U, V ) = X (u,i)M (Mu,i r X Uu,k Vi,k )2 + k=1 X 2 Uu,k + u,k X 2 Vi,k i,k ( is a hyper-parameter controlling the degree of penalization.) (c) Implement myRecommender.m by filling the gradient descent part. You are given a skeleton code myRecommender.m. Using the training data rateMatrix, you will implement your own recommendation system of rank lowRank. The only file you need to edit and submit is myRecommender.m. In the gradient descent part, repeat your update formula in (b), observing the average reconstruction error between your estimation and ground truth in training set. You need to set a stopping criteria, based on this reconstruction error as well as the maximum number of iterations. You should play with several different values for and to make sure that your final prediction is accurate. Formatting information is here: Input rateMatrix: training data set. Each row represents a user, while each column an item. Observed values are one of {1, 2, 3, 4, 5}, and missing values are 0. lowRank: the number of factors (dimension) of your model. With higher values, you would expect more accurate prediction. Output U: the user profile matrix of dimension user count low rank. V: the item profile matrix of dimension item count low rank. 4 Evaluation [15 pts] Upload your myRecommender.m implementation file. (Do not copy and paste your code in your report. Be sure to upload your myRecommender.m file.) To test your code, try to run homework3.m. You may have noticed that the code prints both training and test error, in RMSE (Root Mean Squared Error), defined as follows: X (Mu,i f (u, i))2 (u,i)M where f (u, i) is your estimation, and the summation is over the training set or testing set, respectively. For the grading, we will use another set-aside testing set, which is not released to you. If you observe your test error is less than 1.00 without cheating (that is, training on the test set), you may expect to see the similar performance on the unseen test set as well. Note that we provide homework3.m just to help you evaluate your code easily. You are not expected to alter or submit this to us. In other words, we will not use this file when we grade your submission. The only file we take care of is myRecommender3.m. Grading criteria: Your code should output U and V as specified. The dimension should match to the specification. We will test your output on another test dataset, which was not provided to you. The test RMSE on this dataset should be at least 1.05 to get at least partial credit. We will measure elapsed time for learning. If your implementation takes longer than 3 minutes for rank 5, you should definitely try to make your code faster or adjust parameters. Any code running more than 5 minutes is not eligible for credit. Your code should not crash. Any crashing code will be not credited. Report [10 pts] In your report, show the performance (RMSE) both on your training set and test set, with varied lowRank. (The default is set to 1, 3, and 5, but you may want to vary it further.) Discuss what you observe with varied low rank. Also, briefly discuss how you decided your hyper-parameters (, ). Note Do not print anything in your code (e.g, iteration 1 : err=2.4382) in your final submission. Do not alter input and output format of the skeleton file. (E.g, adding a new parameter without specifying its defalut value) Please make sure that you returned all necessary outputs according to the given skeleton. Please do not use additional file. This task is simple enough that you can fit in just one file. Submit your code with the best parameters you found. We will grade without modifying your code. (Applying cross-validation to find best parameters is fine, though you do not required to do.) Please be sure that your program finishes within a fixed number of iterations. Always think of a case where your stopping criteria is not satisfied forever. This can happen anytime depending on the data, not because your code is incorrect. For this, we recommend setting a maximum number of iteration in addition to other stopping criteria. 5 Grand Prize Similar to the Netflix competition held in 2006 to 2009, the student who achives the lowest RMSE on the secret test set will earn the Grand Prize. We will give extra 10 bonus points to the winner, and share the student's code to everyone. (Note that the winner should satisfy all other grading criteria perfectly, including answer sanity check and timing requirement. Otherwise, the next student will be considered as the winner.) Typing Bonus As usual, we will give 5 bonus points for typed submissions. Note that all questions should be typed to get this credit. 6

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Algebra I Dummies

Authors: Mary Jane Sterling

1st Edition

1119843049, 978-1119843047

More Books

Students also viewed these Mathematics questions

Question

Use Case Modeling

Answered: 1 week ago