brunch

You can make anything
by writing

C.S.Lewis

by 라인하트 Nov 28. 2020

앤드류 응의 머신러닝(14-5): PCA 데이터 재구성

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



Dimensionality Reduction 

(차원 축소)


Applying PCA (PCA 적용)  


Reconstruction from Compressed Representation

(압축 표현의 재구성)    


   In some of the earlier videos, I was talking about PCA as a compression algorithm where you may have say, 1,000-dimensional data and compress it to 100-dimensional feature vector. Or have three-dimensional data and compress it to a two-dimensional representation. So, if this is a compression algorithm, there should be a way to go back from this compressed representation back to an approximation of your original high-dimensional data. So given zi, which may be 100-dimensional, how do you go back to your original representation, xi which was maybe a 1000-dimensional. In this video, I'd like to describe how to do that.


   지난 강의에서 PCA를 압축 알고리즘이라고 설명했습니다. PCA는 1,000차원의 데이터를 100차원 피처 벡터로 압축합니다. 또는 3차원 데이터를 2차원 데이터로 압축합니다. 압축 알고리즘이라는 표현에서 저차원 데이터를 원래의 고차원 데이터의 근사치로 복원할 방법이 필요합니다. 100차원인 z^(i)가 어떻게 원래의 고차원 1,000 차원 데이터로 복원할 수 있을까요? 요? 이번 강의는 저차원 데이터를 고차원 데이터로 복원하는 방법을 설명합니다.



   In the PCA algorithm, we may have an example like this, so maybe that's my example x1, and maybe that's my example x2. And what we do is we take these examples, and we project them onto this one dimensional surface. And then now we need to use a real number, say z1, to specify the location of these points after they've been projected onto this one dimensional surface. So, given the point z1, how can we go back to this original two dimensional space? In particular, given the point z, which is R, can we map this back to some approximate representation x and R2 of whatever the original value of the data was? 


   여기 PCA 알고리즘 예제가 있습니다. 녹색 예제는  x^(1), 황색 예제는 x^(2)입니다. 2차원 데이터를 1차원 표면에 투영합니다. 1차원에 투영한 데이터의 위치는 x^(1) 예제는 z^(1)으로, x^(2) 예제는 z^(2)로 나타냅니다. z는 R^(1)차원 벡터이고, X는 R^(2)차원 벡터입니다. 1차원 데이터를 원래의 2차원 데이터로 복원할 수 있을까요?

   So whereas z equals Ureduce transpose x, if you want to go in the opposite direction, the equation for that is, we're going to write Xapprox equals Ureduce, times z. And again, just to check the dimensions, here Ureduce is going to be an n by k dimensional vector, z is going to be k by one dimensional vector. So you multiply these out that's going to be n by one, so Xapprox is going to be an n dimensional vector. And so the intent of PCA, that is if the square projection error is not too big, is that this Xapprox will be close to whatever was the original value of x that you have used to derive z in the first place. To show a picture of what this looks like, this is what it looks like. What you get back of this procedure are points that lie on the projection of that, onto the green line. 

   So to take our early example, if we started off with this value of x1, and we got this value of z1, if you plug z1 through this formula to get x1 approx, then this point here, that would be x1 approx, which is going to be in R2. And similarly, if you do the same procedure, this would be x2 approx. And that's a pretty decent approximation to the original data. So that's how you go back from your low dimensional representation z, back to an uncompressed representation of the data. We get back an approximation to your original data x. And we also call this process reconstruction of the original data where we think of trying to reconstruct the original value of x from the compressed representation.


   저차원으로 압축할 때 공식은 다음과 같습니다.

      반대로 고차원으로 되돌릴 때 방정식은 다음과 같습니다. 

   Ureduce는 n X k 차원 벡터이고, z는 k X 1차원 벡터입니다. 두 행렬을 곱하면 n X 1차원입니다. 따라서 xapprox는 n 차원 벡터입니다. PCA의 최적화 목표는 투영 오차의 제곱을 최소화합니다. xapprox는 원래 X의 값에 가깝습니다. 오른쪽 그림은 1차원에서 되돌아간 2차원 데이터를 보여줍니다. 이 방정식으로 얻는 xapprox는 녹색 선에 투영점 점들입니다. 

    x^(1)에서 z^(1)의 값을 얻었고, 다시 z^(1)에서 x^(1)의 근사치  x^(1)approx를 얻었습니다. 동일한 방법으로 z^(2)에서 x^(2)의 근사치 x^(2)approx를 얻습니다. 근사치는 꽤 괜찮은 값으로 원래 데이터에 가깝습니다.이것이 저 차원 데이터에서 고차원 데이터로 복원하는 방법입니다. 압축된 데이터 z에서 원래 x의 값을 재구성하는 절차를 재구성(Reconstruction)이라고 합니다. 

     

   So, given an unlabeled data set, you now know how to apply PCA and take your high dimensional features x and map that to this lower-dimensional representation z. And from this video hopefully you now also know how to take these low-representation z and map it back up to an approximation of your original high-dimensional data. Now that you know how to implement and apply PCA, what I'd like to do next is talk about some of the mechanics of how to actually use PCA well. And in particular in the next video, I'd like to talk about how to choose k, which is how to choose the dimension of the reduced representation vector z.


   따라서, PCA 알고리즘은 레이블이 없는 고차원 데이터 셋 X를 저 차원 데이터 Z에 매핑합니다. 이번 강의에서 저차원 데이터 셋 X를 원래의 고차원 데이터 셋 X의 근사치 Xapprox로 매핑하는 것을 설명했습니다. 다음으로 PCA를 실제로 잘 사용하는 방법에 대한 몇 가지 메커니즘을 설명할 것입니다. 특히, 다음 비디오에서는 축소된 표현 벡터 z의 차원을 선택하는 방법인 k를 선택하는 방법을 설명합니다.



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




정리하며


   PCA는 n차원의 데이터를 k차원으로 압축하는 알고리즘입니다. 즉, PCA는 1,000차원의 데이터를 100차원의 피처 벡터로 압축합니다. 따라서, 압축된 데이터는 k차원에서 n차원의 근사치로 되돌 수 있습니다. 




  압축된 데이터 z에서 원래 x의 값을 재구성하는 프로세스를 재구성(Reconstruction)이라고 합니다. 



문제풀이




정답은 1번, 2번, 3번입니다. 

매거진의 이전글 앤드류 응의 머신러닝(14-4): PCA 알고리즘
작품 선택
키워드 선택 0 / 3 0
댓글여부
afliean
브런치는 최신 브라우저에 최적화 되어있습니다. IE chrome safari