brunch

You can make anything
by writing

C.S.Lewis

by 라인하트 Dec 09. 2020

앤드류 응의 머신러닝(16-2):콘텐츠 기반 추천시스템

   온라인 강의 플랫폼 코세라의 창립자인 앤드류 응 (Andrew Ng) 교수는 인공지능 업계의 거장입니다. 그가 스탠퍼드 대학에서 머신 러닝 입문자에게 한 강의를 그대로 코세라 온라인 강의 (Coursera.org)에서 무료로 배울 수 있습니다. 이 강의는 머신러닝 입문자들의 필수코스입니다. 인공지능과 머신러닝을 혼자 공부하면서 자연스럽게 만나게 되는 강의입니다. 


Recommender Systems   

(추천 시스템)


Predicting Movie Ratings

(영화 등급 예측)     


Content Based Recommendation (콘텐츠 기반 추천 시스템)   


   In the last video, we talked about the recommender systems problem where for example you might have a set of movies and you may have a set of users, each who have rated some subset of the movies. They've rated the movies one to five stars or zero to five stars. And what we would like to do is look at these users and predict how they would have rated other movies that they have not yet rated. In this video I'd like to talk about our first approach to building a recommender system. This approach is called content based recommendations. 


   지난 강의에서 추천 시스템 문제를 다루었습니다. 예를 들어 영화가 세 편이 있고, 자기가 본 영화를 평가한 사용자가 셋이 있습니다. 사용자들은 별 1개에서 5개까지 또는 별 0개에서 5개로 평가했습니다. 추천 시스템은 사용자들이 아직 평가하지 않은 영화들을 어떻게 평가할지를 예측합니다. 이번 강의에서 추천 시스템을 구축하는 첫 번째 접근 방법인 콘텐츠 기반 추천을 설명합니다. 



    Here's our data set from before and just to remind you of a bit of notation, I was using nu to denote the number of users and so that's equal to 4, and nm to denote the number of movies, I have 5 movies. So, how do I predict what these missing values would be? 


   여기 지난 강의에서 활용한 데이터 셋이 있습니다. 지난 강의에서 배운 표기법을 상기해 봅시다. 사용자 수를 나타내는 nu = 4이고, 영화의 수를 나타내는 nm = 5입니다. 분홍색 동그라미를 그린 ? 의 값을 어떻게 예측할 수 있을까요? 



Let's suppose that for each of these movies I have a set of features for them. In particular, let's say that for each of the movies have two features which I'm going to denote x1 and x2. Where x1 measures the degree to which a movie is a romantic movie and x2 measures the degree to which a movie is an action movie. So, if you take a movie, Love at last, you know it's 0.9 rating on the romance scale. This is a highly romantic movie, but zero on the action scale. So, almost no action in that movie. Romance forever is a 1.0, lot of romance and 0.01 action. I don't know, maybe there's a minor car crash in that movie or something. So there's a little bit of action. Skipping one, let's do Swords vs karate, maybe that has a 0 romance rating and no romance at all in that but plenty of action. And Nonstop car chases, maybe again there's a tiny bit of romance in that movie but mainly action. And Cute puppies of love mainly a romance movie with no action at all. 

   


   영화의 특징을 나타낼 수 있는 피처를 생성합니다. 여기서 로맨스 척도를 나타내는 피처 x1과 액션 척도를 나타내는 피처 x2를 사용합니다. 


   '마침내 사랑'은 로맨스 척도 x1은 0.9로 매우 낭만적인 영화이지만 액션 척도 x2는 0으로 거의 액션이 없습니다. 

   '영원한 로맨스'는 로맨스 척도 x1은 1.0이고 액션 척도 x2는 0.01입니다. 아마 영화에 교통사고와 같은 약간의 액션이 있을 것입니다. 

   '사랑스러운 귀염둥이'는 로맨스 척도 x1이 0.99이고 액션 척도 x2는 0입니다. 전혀 액션이 없는 로맨스 영화입니다. 

   '논스톱 자동차 추격전'은 로맨스 척도 x1은 0.1, 액션 척도 x2가 1.0입니다. 약간의 로맨스는 있지만 주로 액션이 있습니다. 

   '검 대 가라테'는 로맨스 척도 x1은 0이고 액션은 0.9입니다. 로맨스는 전혀 없지만 많은 액션이 있습니다. 



    So if we have features like these, then each movie can be represented with a feature vector. Let's take movie one. So let's call these movies 1, 2, 3, 4, and 5. But my first movie, Love at last, I have my two features, 0.9 and 0. And so these are features x1 and x2. And let's add an extra feature as usual, which is my interceptor feature x0 = 1. And so putting these together I would then have a feature x1. The superscript 1 denotes it's the feature vector for my first movie, and this feature vector is equal to 1. The first 1 there is this interceptor. And then my two feature is 0.90 like so. So for Love at last I would have a feature vector x1, for the movie Romance forever I may have a software feature of vector x2, and so on, and for Swords vs karate I would have a different feature vector x superscript 5. Also, consistence with our earlier node notation that we were using, we're going to set n to be the number of features not counting this x0 interceptor. So n is equal to 2 because it's we have two features x1 and x2 capturing the degree of romance and the degree of action in each movie. 


   5개의 영화의 특징을 피처 벡터로 표현합니다. '마침내 사랑'부터 차례대로  x^(1), x^(2),..., x^(5)로 인덱스를 표시합니다. 마침내 사랑은 피처 벡터 x^(1)이고 , 영원한 로맨스는 피처 벡터 x^(2)이고, 마지막 검대 가라테는 피처 벡터 x^(5)입니다. 영화에 평소대로 인터셉터 피처 x0 = 1을 추가합니다. 표기법의 일관성을 유지하기 위해 피처의 수 n을 사용할 때는 인터셉터 x0를 계산하지 않고 n = 2라고 설정합니다. 영화에 대한 피처를 로맨스 척도 x1와 액션 척도 x2를 사용하고 인터셉트 피처는 계산하지 않습니다.  



   Now in order to make predictions here's one thing that we do which is that we could treat predicting the ratings of each user as a separate linear regression problem. So specifically, let's say that for each user j, we're going to learn the parameter vector theta j, which would be an R3 in this case. More generally, theta (j) would be an R (n+1), where n is the number of features not counting the set term. And we're going to predict user j as rating movie i with just the inner product between parameters vectors theta and the features xi. So let's take a specific example. Let's take user 1, so that would be Alice. And associated with Alice would be some parameter vector theta 1. And our second user, Bob, will be associated a different parameter vector theta 2. Carol will be associated with a different parameter vector theta 3 and Dave a different parameter vector theta 4. 

   So let's say you want to make a prediction for what Alice will think of the movie Cute puppies of love. Well that movie is going to have some parameter vector x3 where we have that x3 is going to be equal to 1, which is my intercept term and then 0.99 and then 0. And let's say, for this example, let's say that we've somehow already gotten a parameter vector theta 1 for Alice. We'll say it later exactly how we come up with this parameter vector. But let's just say for now that some unspecified learning algorithm has learned the parameter vector theta 1 and is equal to this 0,5,0. So our prediction for this entry is going to be equal to theta 1, that is Alice's parameter vector, transpose x3, that is the feature vector for the Cute puppies of love movie, number 3. And so the inner product between these two vectors is gonna be 5 times 0.99, which is equal to 4.95. And so my prediction for this value over here is going to be 4.95. And maybe that seems like a reasonable value if indeed this is my parameter vector theta 1. So, all we're doing here is we're applying a different copy of this linear regression for each user, and we're saying that what Alice does is Alice has some parameter vector theta 1 that she uses, that we use to predict her ratings as a function of how romantic and how action packed a movie is.  And Bob and Carol and Dave, each of them have a different linear function of the romanticness and actionness, or degree of romance and degree of action in a movie and that that's how we're gonna predict that their star ratings.


   이제 예측을 하기 위해 각 사용자의 선호도를 예측하기 위한 선형 회귀 문제로 처리합니다. 구체적으로. 각 사용자 j에 대한 파라미터 벡터 θ^(j)를 학습합니다. 이 예제에서 θ^(j)는 R^(3) 차원입니다. 이유는 θ^(j)는 R^(n+1) 차원이기 때문입니다. n은 피처의 수입니다. 여기서 파라미터 벡터 θ^(j)와 피처 벡터 x^(i) 사이의 내적으로 사용자 j의 영화 i에 대한 등급을 예측합니다. 예를 들어, 첫 번째 사용자 앨리스는 파라미터 벡터 θ^(1)와 연결합니다. 두 번째 사용자 밥은 파라미터 벡터 θ^(2)와 연결합니다. 세 번째 사용자 캐럴은 파라미터 벡터 θ^(3)과 연결합니다. 네 번째 사용자 데이브는 파라미터 벡터 θ^(4)와 연결합니다.


    앨리스가 영화 사랑스러운 귀염둥이에 대해 어떻게 생각할지를 예측한다고 가정합니다. 사랑스러운 귀염둥이의 피처 파라미터 벡터 x^(3)입니다. x3 = [1, 0.99, 0]입니다. 여기서 앨리스에 대한 파라미터 벡터 θ^(1) = [0, 5, 0]으로 이미 얻었다고 가정합니다. 이 파라미터 벡터 θ^(1)을 어떻게 만드는지는 나중에 정확하게 설명할 것입니다. 지금은 학습 알고리즘이 파라미터 벡터 θ^(1)을 학습하였고, 로맨스 척도는 5로 액션 척도는 0으로 표시하였습니다. 앨리스의 파라미터 벡터 θ^(1)은 R^(3)의 피처 벡터입니다. 따라서 두 벡터의 내적은 다음과 같습니다. 


   이것이 파라미터 벡터 θ^(1)의 값이고, 합리적인 값처럼 보입니다. 이제 각 사용자에 대해 선형 회귀를 적용합니다. 앨리스의 파라미터 벡터 θ^(1)는 앨리스가 로맨틱 영화를 얼마나 좋아하고 액션 영화를 얼마나 좋아하는지를 예측하고 평가합니다. 그리고 밥과 캐럴과 데이브는 로맨스와 액션에 대한 각각의 피처가 있고 좋아하는 정도가 있습니다. 이것이  사용자들의 별 등급을 예측하는 방법입니다. 


   More formally, here's how we can write down the problem. Our notation is that r(i, j) is equal to 1 if user j has rated movie i and y(i, j) is the rating of that movie, if that rating exists. That is, if that user has actually rated that movie. And, on the previous slide we also defined these, theta j, which is a parameter for the user xi, which is a feature vector for a specific movie. And for each user and each movie, we predict that rating as follows. 


   수학적으로 콘텐츠 기반 추천 방식을 정리합니다.  

      r(i, j) = 1은 사용자 j가 영화 i를 평가

      y^(i, j)는 사용자 j가 영화 i를 평가한 등급  


   여기서, 해당 사용자가 실제로 해당 영화를 평가한 경우입니다. 

      x^(i)는 영화 i에 대한 피처 벡터

      θ^(j)는 사용자 j에 대한 영화 취향을 나타내는 피처 벡터


   각 사용자 j와 각 영화 i에 대해 다음과 같이 등급을 예측합니다.   



  So let me introduce just temporarily introduce one extra bit of notation mj. We're gonna use mj to denote the number of users rated by movie j. We don't need this notation only for this line. Now in order to learn the parameter vector for theta j, well how do we do so. This is basically a linear regression problem. So what we can do is just choose a parameter vector theta j so that the predicted values here are as close as possible to the values that we observed in our training sets and the values we observed in our data. So let's write that down. In order to learn the parameter vector theta j, let's minimize over the parameter vector theta j of sum, and I want to sum over all movies that user j has rated. So we write it as sum over all values of i. That's a :r(i, j) equals 1. So the way to read this summation syntax is this is summation over all the values of i, so the r(i.j) is equal to 1. So you'll be summing over all the movies that user j has rated. And then I'm going to compute theta j, transpose x i. So that's the prediction of using j's rating on movie i,- y (i, j). So that's the actual observed rating squared. And then, let me just divide by the number of movies that user j has actually rated. So let's just divide by 1 over 2m j. And so this is just like the least squares regressions. It's just like linear regression, where we want to choose the parameter vector theta j to minimize this type of squared error term. 


   여기서, 파라미터 벡터   θ^(j)를 학습하기 위해 무엇을 해야 할까요? 이것은 기본적으로 선형 회귀 문제입니다. 사용자 j의 i 번째 영화에 대한 선호도를 예측하는 항은 θ^(j))^T(x^(i)이고, 사용자 j가 i 번째 영화에 대해 실제 평가한 등급을 나타내는 항은 y^(i, j)입니다. 두 항의 제곱의 값을 최소화합니다. 여기서, r(i, j) = 1인 영화인 j 번째 영화는 사용자 j가 실제로 평가를 한 영화에 대해서 다룹니다. 추천 알고리즘의 목표는  예측 값과 사용자가 실제로 평가한 값이 최대한 가깝게 만드는 것입니다. 

   여기서파라미터 벡터 θ^(j)를 학습하기 위해 오차의 제곱 함수를 r(i, j) = 1일 때 사용자 j가 평가한 영화 i에 대한 등급을 합산 후 평가한 영화의 수로 나눕니다. 이것은 오차의 제곱항을 최소 하기 위한 파라미터  θ^(j)를 선택하는 선형 회귀와 같습니다. 



   And if you want, you can also add in regularization terms so plus lambda over 2m and this is really 2mj because we have mj examples. User j has rated that many movies, it's not like we have that many data points with which to fit the parameters of theta j. 

   여기에 정규화 항을 추가할 수 있습니다.  사용자 j는 많은 영화를 평가하고 등급을 매겼습니다. 파라미터 θ^(j)에 적합한 데이터가 많지 않습니다. 



   And then let me add in my usual regularization term here of theta j k squared. As usual, this sum is from k equals 1 through n, so here, theta j is going to be an n plus 1 dimensional vector, where in our early example n was equal to 2. But more broadly, more generally n is the number of features we have per movie. And so as usual we don't regularize over theta 0. We don't regularize over the bias terms. The sum is from k equals 1 through n. So if you minimize this as a function of theta j you get a good solution, you get a pretty good estimate of a parameter vector theta j with which to make predictions for user j's movie ratings.

   For recommender systems, I'm gonna change this notation a little bit. So to simplify the subsequent math, I with to get rid of this term mj. So that's just a constant, right? So I can delete it without changing the value of theta j that I get out of this optimization. So if you imagine taking this whole equation, taking this whole expression and multiplying it by mj, get rid of that constant. And when I minimize this, I should still get the same value of theta j as before. 


  그리고, 여기에 (θ^(j) k)^2에 대한 합산을 추가합니다.  평소와 같이 합산 Σ는 k = 1에서 n까지 입니다. θ^(j)는 R^(n+1) 차원의 벡터입니다. 초기 예제에서 n = 2 였습니다. 더 넓게 보면 n은 영화에 대한 피처의 수입니다. θ^(0)는 정규화하지 않습니다. 따라서 합산은 n = 1부터 n까지입니다. θ^(j)의 함수를 최소화하면, 사용자 j의 영화 등급을 예측하기 위한 파라미터 θ^(j)에 대해 꽤 좋은 추정치를 얻을 수 있습니다. 

   추천 시스템에서 공식을 약간 변경하겠습니다. 단순히 수학적으로 단순화하기 위해 m^(j)를 제거합니다. m^(j)는 단지 상수입니다. 따라서, 최적화한 θ^(j)의 값을 변경하지 않고 삭제할 수 있습니다. 이 전체 방정식에서 m^(j)를 곱하는 것을 상상하면 상수를 제거할 수 있습니다. m^(j)를 제거해도 θ^(j)의 값은 동일합니다.  



   So just to repeat what we wrote on the previous slide, here's our optimization objective. In order to learn theta j which is the parameter for user j, we're going to minimize over theta j of this optimization objectives. So this is our usual squared error term and then this is our regularizations term. Now of course in building a recommender system, we don't just want to learn parameters for a single user. We want to learn parameters for all of our users. I have n subscript u users, so I want to learn all of these parameters. And so, what I'm going to do is take this optimization objective and just add the mixture summation there. So this expression here with the one half on top of this is exactly the same as what we had on top. Except that now instead of just doing this for a specific user theta j, I'm going to sum my objective over all of my users and then minimize this overall optimization objective, minimize this overall cost on. And when I minimize this as a function of theta 1, theta 2, up to theta nu, I will get a separate parameter vector for each user. And I can then use that to make predictions for all of my users, for all of my n subscript users. 

   앞에서 작성한 수학 공식을 다시 정리합니다. 여기 최적화 목표가 있습니다. 사용자 j의 영화 취향에 대한 파라미터 θ^(j)를 학습하기 위해 최적화 목표는 θ^(j)를 최소화합니다. 앞의 항은 일반적인 오차의 제곱항이고, 뒤의 항은 정규화 항입니다. 추천 시스템을 구축할 때 단일 사용자에 대한 파라미터만을 구축하지 않습니다. 모든 사용자에 대한 영화 취향에 대한 파라미터 θ^(j)를 학습해야 합니다. nu는 사용자의 수이고, θ^(nu)는 사용자에 대한 영화 취향을 나타냅니다. 최적화 목표를 단 한 명의 사용자가 아닌 모든 nu사용자에 대해 적용할 수 있는 수학 공식을 만듭니다. 즉, 모든 사용자에 대한 최적화 목표를 최소화하고 전체 비용을 최소화합니다. θ^(1), θ^(2),..., θ^(nu)까지의 함수로 최소화하면 각 사용자에 대한 별도의 파라미터 벡터를 얻습니다. 그런 다음 모든 사용자, n명의 구독자 모두를 예측합니다. 



   So putting everything together, this was our optimization objective on top. And to give this thing a name, I'll just call this J(theta1,..., theta nu). So j as usual is my optimization objective, which I'm trying to minimize. Next, in order to actually do the minimization, if you were to derive the gradient descent update, these are the equations that you would get. So you take theta j, k, and subtract from an alpha, which is the learning rate, times these terms over here on the right. So there's slightly different cases when k equals 0 and when k does not equal 0. Because our regularization term here regularizes only the values of theta jk for k not equal to 0, so we don't regularize theta 0, so with slightly different updates when k equals 0 and k is not equal to 0. And this term over here, for example, is just the partial derivative with respect to your parameter, that of your optimization objective. Right and so this is just gradient descent and I've already computed the derivatives and plugged them into here. And if this gradient descent update look a lot like what we have here for linear regression. That's because these are essentially the same as linear regression. The only minor difference is that for linear regression we have these 1 over m terms, this really would've been 1 over mj.    But because earlier when we are deriving the optimization objective, we got rid of this, that's why we don't have this 1 over m term. But otherwise, it's really some of my training examples of the ever times xk plus that regularization term, plus that term of regularization contributes to the derivative.


   모든 것을 합치면 모든 사용자를 위한 최적화 목표를 계산할 수 있습니다. 

이것을 J(θ^(1), θ^(2),..., θ^(nu))라고 합니다. 그래서 비용 함수 J는 평소와 같이 최적화 목표이며 최소화합니다. 다음은 실제로 최소화를 수행하기 위한 경사 하강법 업데이트입니다. 


      

   여기서, α는 학습률입니다. 그리고 k = 0 일 때와 k 가 0이 아닐 때 약간 다릅니다. 여기 {} 안의 값은 편미분입니다. 이것은 단지 경사 하강법이고 미분항을 계산합니다. 선형 회귀의 경사 하강법 업데이트가 매우 비슷해 보인다면, 본질적으로 선형 회귀와 동일하기 때문입니다. 유일한 차이점은 선형 회귀는 1/m 항이 있다는 것입니다. 실제로 1/m^(j)가 있지만 생략되었습니다. 이전 슬라이드에서 최적화 목표를 도출할 때 제거했기 때문에 1/m에 없습니다. 


   And so if you're using gradient descent here's how you can minimize the cost function j to learn all the parameters. And using these formulas for the derivative if you want, you can also plug them into a more advanced optimization algorithm, like conjugate gradient or LBFGS or what have you. And use that to try to minimize the cost function j as well. So hopefully you now know how you can apply essentially a deviation on linear regression in order to predict different movie ratings by different users. This particular algorithm is called a content based recommendations, or a content based approach, because we assume that we have available to us features for the different movies. And so where features that capture what is the content of these movies, of how romantic is this movie, how much action is in this movie. And we're really using features of a content of the movies to make our predictions.


   비용 함수 J를 경사 하강법으로 최소화하고 모든 파라미터를 학습할 수 있습니다. 미분항을 사용하여 공역기울기법이나 LBFGS와 같은 고급 최적화 알고리즘을 사용하여 비용 함수 J를 최소화할 수 있습니다. 사용자가 영화 등급을 예측하기 위해 본직적으로 선형 회귀에 대한 미분을 적용할 수 있는 방법을 배웠습니다. 영화의 특징에 대한 피처를 사용하는 알고리즘을 콘텐츠 기반 추천 또는 콘텐츠 기반 접근 방식이라고 합니다. 즉, 피처는 영화에 대한 로맨틱 척도와 액션 척도를 포착합니다. 실제로 영화 콘텐츠의 피처를 사용하여 예측합니다. 

    

   But for many movies, we don't actually have such features. Or maybe very difficult to get such features for all of our movies, for all of whatever items we're trying to sell. And so, in the next video, we'll start to talk about an approach to recommender systems that isn't content based and does not assume that we have someone else giving us all of these features for all of the movies in our data set.


   그러나, 많은 영화들은 실제로 그런 피처를 사용하지 않습니다. 판매 가능한 모든 영화에 대해 이런 피처를 적용하는 것은 매우 어렵습니다. 따라서, 다음 강의에서 콘텐츠 기반이 아닌 데이터 셋의 모든 영화에 대해 모든 피처를 제공하는 무엇인가가 있다고 가정하지 않는 추천 시스템을 다룰 것입니다. 


앤드류 응의 머신러닝 동영상 강의 



정리하며


   영화 추천 시스템은 사용자들이 아직 평가하지 않은 영화들을 어떻게 평가할지를 예측하는 것입니다. 그래서, 추천 영화에 대한 시청률과 구매율을 높이는 것이 목적입니다.  


   첫 번째로 콘텐츠 기반 추천 알고리즘을 다룹니다. 콘텐츠 기반 필터링은 영화 또는 팝송과 같은 콘텐츠를 분석한 콘텐츠 프로파일(x^(i)과 사용자 선호도를 분석한 사용자 프로파일 (θ^(nu))을 구축한 후 사용자 선호에 맞는 콘텐츠를 추천합니다. 예를 들면, 음악 사이트 판도라는 신곡이 출시될 때마다 장르, 비트, 음색 등 400여 개 항목의 피처를 추출합니다. 사용자 파일과 신곡 콘텐츠 프로파일을 비교하여 좋아할 만한 사용자에게 추천합니다. 


   콘텐츠 기반 추천이 어떻게 동작하는 지를 정리합니다. 


1) 각 영화의 특성에 대한 프로파일을 생성합니다. 

    누군가 또는 어떤 프로그램이 각 영화에 대해 일련의 피처를 생성한다고 가정합니다. x1은 로맨틱 영화의 정도를 측정하고, x2는 액션 영화의 정도를 측정합니다. 예를 들면, 첫 번째 영화 마침내 사랑의 프로파일 x^(1) = [1, 0.9, 0]으로 3차원 벡터입니다. 늘 하듯이 인터셉터 피처 x0 = 1을 추가하였습니다. 마침내 사랑은 로맨틱 척도가 0.9이지만 액션 척도는 0입니다.


2) 사용자의 선호도를 나타내는 사용자 프로파일 생성합니다. 

   누군가 또는 어떤 프로그램이 각 사용자 j에 대한 파라미터 벡터 θ^(j)를 학습한다고 가정합니다. 예를 들면, 첫 번째 사용자 앨리스 θ^(1) = [0; 5; 0]입니다. 영화에 대한 프로파일과 동일한 이 예제에서 θ^(j)는 R^(3) 차원 벡터입니다. 


3) 사용자가 평가하지 않은 영화에 대한 등급 또는 선호도를 예측합니다. 

    r(i, j) = 1은 사용자 j가 영화 i에 대해 평가한 영화입니다. 사용자 j가 영화 i에 실제로 평가한 선호도 또는 등급은 y(i, j)입니다.  따라서, r(i, j) = 0인 영화에 대해 사용자 j의 선호를 측정하기 위해 다음과 같은 공식을 사용합니다.   파라미터 벡터 θ^(j)와 피처 벡터 x^(i) 사이의 내적으로 사용자 j의 영화 i에 대한 등급을 예측합니다. 예를 들면, 앨리스가 보지 않은 3번째 영화에 대한 앨리스의 선호는 다음과 같습니다.


   여기서, 영화의 특성에 대한 프로파일은 있지만, 사용자의 선호도를 나타내는 프로파일을 알 수 없을 때, 사용자 프로파일 θ^(j)를 예측하는 과정을 정리합니다.


사용자의 선호도를 나타내는 사용자  프로파일 생성하기

   파라미터 벡터   θ^(j)를 학습하는 과정은 선형 회귀 문제입니다. 파라미터 벡터 θ^(j)를 예측한 값은 학습 셋에서 관찰한 값과 가능한 한 가까워야 합니다. 이것을 수학 공식으로 정리합니다.


   여기서, 사용자 j의 사용자 프로파일을 작성합니다. 사용자 j가 i 번째 영화에 대한 선호도를 예측하는 항은 θ^(j))^T(x^(i)이고, 사용자 j가 i 번째 영화에 대해 실제 평가한 등급을 나타내는 항은 y^(i, j)입니다. 파라미터 벡터 θ^(j)를 학습하기 위해 오차의 제곱 함수를 r(i,j) = 1일 때 사용자 j가 평가한 영화 i에 대한 등급을 합산 후 평가한 영화의 수로 나눕니다. 이것은 오차의 제곱항을 최소 하기 위한 파라미터  θ^(j)를 선택하는 선형 회귀와 같습니다. 여기서, 정규 화항을 추가합니다. 그리고, 영화의 특성을 나타내는 피처의 수만큼 합산하기 위해 k = 1에서 n까지 추가합니다. 그리고, m^(j)를 삭제합니다. 

  이것을 모든 사용자에 대한 사용자 프로파일을 예측하고, 이 값을 모두 합산합니다. 그리고, 이 합산한 값을 최소화합니다.

      여기서, 선형 회귀의 경사 하강법 업데이트와 본질적으로 동일합니다. 유일한 차이점은 선형 회귀는 1/m 항이 있다는 것입니다. 


문제 풀이




정답은 4번입니다. 

매거진의 이전글 앤드류 응의 머신러닝(16-1): 추천 시스템 개요
작품 선택
키워드 선택 0 / 3 0
댓글여부
afliean
브런치는 최신 브라우저에 최적화 되어있습니다. IE chrome safari