brunch

You can make anything
by writing

C.S.Lewis

by 라인하트 Dec 08. 2020

앤드류 응의 머신러닝(15-8):다변량정규분포이상탐지

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


Anomaly Detection  

(이상 탐지)


Multivariate Gaussian Distribution

(다변량 가우시안 분포)    


Anomaly Detection using the Multivariate Gaussian Distribution 

(다변량 가우시안 분포를 사용하는 이상 탐지)   


   In the last video we talked about the Multivariate Gaussian Distribution and saw some examples of the sorts of distributions you can model, as you vary the parameters, mu and sigma. In this video, let's take those ideas, and apply them to develop a different anomaly detection algorithm. 


   지난 강의에서 다변량 가우시안 분포를 설명했고, 평균 파라미터 μ와 분산 파라미터 Σ의 값에 따라 모델링할 수 있는 가우시안 분포의 몇 가지 유형을 살펴보았습니다. 이번 강의에서 다변량 가우시안 분포를 활용하여 이상 탐지 알고리즘을 개발합니다. 



   To recap the multivariate Gaussian distribution and the multivariate normal distribution has two parameters, mu and sigma. Where mu this an n dimensional vector and sigma, the covariance matrix, is an n by n matrix. And here's the formula for the probability of X, as parameterized by mu and sigma, and as you vary mu and sigma, you can get a range of different distributions, like, you know, these are three examples of the ones that we saw in the previous video. 


   다변량 가우시안 분포와 다변량 정규 분포를 요약합니다. 

   가우시안 분포는 평균 파라미터 μ와 분산 파라미터 Σ에 따라 달라집니다. μ는 R^(n) 차원 벡터이고, Σ는 공분산 행렬이자  R^(n X n) 차원 정방 행렬입니다. 여기 두 파라미터를 활용한 p(x; μ, Σ) 확률 공식이 있습니다. μ와 Σ를 변경하면 지난 강의에서 배운 것처럼 다양한 확률 분포를 얻을 수 있습니다. 



   So let's talk about the parameter fitting or the parameter estimation problem. The question, as usual, is if I have a set of examples X1 through XM and here each of these examples is an n dimensional vector and I think my examples come from a multivariate Gaussian distribution. How do I try to estimate my parameters mu and sigma? Well the standard formulas for estimating them is you set mu to be just the average of your training examples. And you set sigma to be equal to this. And this is actually just like the sigma that we had written out, when we were using the PCA or the Principal Components Analysis algorithm. So you just plug in these two formulas and this would give you your estimated parameter mu and your estimated parameter sigma.


   이제 파라미터를 추정하는 방법에 대해 이야기합니다. x^(1), x^(2),..., x^(m)까지의 학습 예제 셋이 있고,  각 예제는 R^(n) 차원의 벡터이자 다변량 가우시안 분포를 따릅니다. 평균 파라미터 μ와 분산 파라미터 Σ를 어떻게 추정할까요? 두 파라미터를 추정하는 표준 공식은 다음과 같습니다. 

   그리고, 이것은 실제로 주성분 분석 알고리즘 PCA (Principal Components Analysis)를 사용할 때 사용한 시그마와 같습니다. 두 공식을 활용하면 두 개의 파라미터를 추정할 수 있습니다.


   So given the data set here is how you estimate mu and sigma. Let's take this method and just plug it into an anomaly detection algorithm. So how do we put all of this together to develop an anomaly detection algorithm? Here 's what we do. First we take our training set, and we fit the model, we fit P of X, by, you know, setting mu and sigma as described on the previous slide.Next when you are given a new example X. So if you are given a test example, lets take an earlier example to have a new example out here. And that is my test example. Given the new example X, what  we are going to do is compute P of X, using this formula for the multivariate Gaussian distribution. And then, if P of X is very small, then we flagged it as an anomaly, whereas, if P of X is greater than that parameter epsilon, then we don't flag it as an anomaly. 


   여기 데이터 셋이 있습니다. 평균 파라미터 μ와 분산 파라미터 Σ를 추정하고 이상 탐지 알고리즘과 연결합니다. 이상 탐지 알고리즘은 어떻게 개발할까요? 학습 셋에서 두 개의 파라미터를 추정하고 확률 p(x)를 모델링합니다. 다음으로 테스트 셋의 예제나 새로운 예제 x가 주어졌을 때, 새로운 예제 x를 다변량 가우스 분포의 공식을 사용하여 p(x)를 계산합니다. p(x)가 엡실론(ε)보다 매우 작으면 이상으로 표시하고, 엡실론(ε) 보다 크면 정상으로 표시합니다. 



   So it turns out, if we were to fit a multivariate Gaussian distribution to this data set, so just the red crosses, not the green example, you end up with a Gaussian distribution that places lots of probability in the central region, slightly less probability here, slightly less probability here, slightly less probability here, and very low probability at the point that is way out here. And so, if you apply the multivariate Gaussian distribution to this example, it will actually correctly flag that example. as an anomaly.


   다변량 가우시안 분포를 데이터 셋에 맞추면 빨간색 예제만 있으면 중앙 영역에 높은 확률을 배치하는 가우스 분포가 됩니다. 그다음 약간 더 적은 확률, 더 적은 확률, 그리고 매우 낮은 확률입니다. 따라서, 녹색 십자가의 예제에 다변량 가우스 분포를 적용하면 이상으로 표시합니다. 



   Finally it's worth saying a few words about what is the relationship between the multivariate Gaussian distribution model, and the original model, where we were modeling P of X as a product of this P of X1, P of X2, up to P of Xn. It turns out that you can prove mathematically, I'm not going to do the proof here, but you can prove mathematically that this relationship, between the multivariate Gaussian model and this original one. And in particular, it turns out that the original model corresponds to multivariate Gaussians, where the contours of the Gaussian are always axis aligned. So all three of these are examples of Gaussian distributions that you can fit using the original model. 


   마지막으로 다변량 가우시안 분포 모델과 원래 모델 사이의 관계를 정리합니다. 원래 모델은 다음과 같이 정의했습니다. 

   다변량 가우시안 분포 모델은 다음과 같습니다. 

   수학적으로 증명할 수 있지만, 여기서 증명하지 않겠습니다. 그러나, 여러분은 다변량 가우시안 모델과 원래 모델 사이의 관계를 수학적으로 증명할 수 있습니다. 원래 모델은 다변량 가우시안 모델에 해당합니다. 여기서 가우스 분포의 등고선은 항상 축에 따라 결정됩니다. 여기 있는 세 가지 그림은 모두 원래 모델을 사용하여 적합시키는 가우스 분포 모델의 사례입니다.  





   It turns out that that corresponds to multivariate Gaussian, where, you know, the ellipses here, the contours of this distribution--it turns out that this model actually corresponds to a special case of a multivariate Gaussian distribution. And in particular, this special case is defined by constrainting the distribution of p of x, the multivariate a Gaussian distribution of p of x, so that the contours of the probability density function, of the probability distribution function, are axis aligned.  And so you can get a p of x with a multivariate Gaussian that looks like this, or like this, or like this. And you notice, that in all 3 of these examples, these ellipses, or these ovals that I'm drawing, have their axes aligned with the X1 X2 axes. And what we do not have, is a set of contours that are at an angle, right? And this corresponded to examples where sigma is equal to 1 1, 0.8, 0.8. Let's say, with non-0 elements on the off diagonals. 


   세 가지 그림은 다변량 가우스 분포 모델에 해당합니다. 여기서 타원은 가우시안 분포의 등고선입니다. 이 그림들은 다변량 가우시안 분포 모델의 특수한 사례입니다. 특수한 사례는 다변량 가우시안 분포 p(x)에 제한 조건을 포함하여 정의한 것입니다. 확률 분포 함수 또는 확률 밀도 함수의 등고선은 축을 따라 정렬합니다. 그래서 여기서 보이는 것처럼 다변량 가우시안 분포를 활용하여 p(x)를 얻을 수 있습니다. 그리고, 세 가지 예 모두 타원은 x1과 x2 축에 정렬합니다. 여기 없는 예제는 비스듬한 타원을 가진 셋입니다. 아마도 Σ = [1, 0.8; 0.8, 1]과 같은 예가 해당합니다. 비대각선의 성분이 0이 아닌 요소가 있다고 가정한 것입니다. 


     

   So, it turns out that it's possible to show mathematically that this model actually is the same as a multivariate Gaussian distribution but with a constraint. And the constraint is that the covariance matrix sigma must have 0's on the off diagonal elements. In particular, the covariance matrix sigma, this thing here, it would be sigma squared 1, sigma squared 2, down to sigma squared n, and then everything on the off diagonal entries, all of these elements above and below the diagonal of the matrix, all of those are going to be zero. And in fact if you take these values of sigma, sigma squared 1, sigma squared 2, down to sigma squared n, and plug them into here, and you know, plug them into this covariance matrix, then the two models are actually identical. That is, this new model, using a multivariate Gaussian distribution, corresponds exactly to the old model, if the covariance matrix sigma, has only 0 elements off the diagonals, and in pictures that corresponds to having Gaussian distributions, where the contours of this distribution function are axis aligned. So you aren't allowed to model the correlations between the different features. So in that sense the original model is actually a special case of this multivariate Gaussian model. 


   따라서, 여기 세 가지 모델은 다변량 가우스 분포이지만 제약 조건이 있다는 것을 수학적으로 보여줄 수 있습니다. 제약 조건은 공분산 행렬 Σ 의 비대각선 성분의 값이 0이어야 한다는 것입니다. 공분산 행렬 Σ 이 대각선 성분이 σ 1^2, σ 2^2,..., σn^2으로 내려갈 것이고, 대각선을 벗어난 나머지 성분은 모두 0입니다. 실제로 σ 1^2, σ 2^2,..., σn^2를 p(x) = p(x; μ, Σ)에 연결하면 두 모델은 실제로 동일합니다. 즉, 다변량 가우시안 분포를 사용하는 새 모델은 공분산 행렬 Σ의 비대각선 성분이 0인 경우입니다. 가우스 분포를 갖는 그림에서 피처는 축에 정렬합니다. 따라서, 다른 피처 간의 상관관계를 모델링할 수 없습니다. 원래 모델은 다변량 가우스 모델의 특별한 경우입니다. 


 


   So when would you use each of these two models? So when would you the original model and when would you use the multivariate Gaussian model? The original model is probably used somewhat more often, and whereas the multivariate Gaussian distribution is used somewhat less but it has the advantage of being able to capture correlations between features. So suppose you want to capture anomalies where you have different features say where features x1, x2 take on unusual combinations of values so in the earlier example, we had that example where the anomaly was with the CPU load and the memory use taking on unusual combinations of values, if you want to use the original model to capture that, then what you need to do is create an extra feature, such as X3 equals X1/X2, you know equals maybe the CPU load divided by the memory used, or something, and you need to create extra features if there's unusual combinations of values where X1 and X2 take on an unusual combination of values even though X1 by itself and X2 by itself looks like it's taking a perfectly normal value. But if you're willing to spend the time to manually create an extra feature like this, then the original model will work fine. Whereas in contrast, the multivariate Gaussian model can automatically capture correlations between different features.


   그렇다면 두 모델을 언제 사용해야 할까요? 원래 모델은 언제 사용하고 다변량 가우스 모델은 언제 사용할까요? 다변량 가우스 모델보다 원래 모델이 더 자주 사용하고 피처 간의 상관관계를 포착할 수 있습니다. 예를 들면, x1과 x2를 조합하여 이상 현상을 포착하려고 한다고 가정합니다. 앞에서 다룬 예에서 x1은 CPU 부하이고 x2는 메모리 사용량입니다. CPU 부하와 메모리 사용량의 상관관계로 이상 현상 포착하기 위한 새로운 피처 x3 = x1 / x2로 정의합니다. CPU 부하를 메모리 사용량으로 나눈 값입니다. x1과 x2의 정상적인 값을 취하는 것처럼 보이지만 추가 기능이 필요합니다. 이러한 종류의 추가 피처를 수동으로 만들기 위해 시간을 할애할 때 원래 모델이 잘 작동합니다. 반면에 다변량 가우시안 분포 모델은 서로 다른 피처 간의 상관관계를 자동으로 포착할 수 있습니다. 



   But the original model has some other more significant advantages, too, and one huge  advantage of the original model is that it is computationally cheaper, and another view on this is that is scales better to very large values of n and very large numbers of features, and so even if n were ten thousand, or even if n were equal to a hundred thousand, the original model will usually work just fine. Whereas in contrast for the multivariate Gaussian model notice here, for example, that we need to compute the inverse of the matrix sigma where sigma is an n by n matrix and so computing sigma if sigma is a hundred thousand by a hundred thousand matrix that is going to be very computationally expensive. And so the multivariate Gaussian model scales less well to large values of N. 


    그러나, 원래 모델에는 다른 더 중요한 장점이 있습니다. 원래 모델은 연산 비용이 저렴합니다. 원래 모델은 n = 10,000 또는 n = 100,000 이더라도 잘 작동합니다. 다변량 가우시안 분포 모델은 공분산 행렬 Σ가 R^(n X n) 차원입니다. 행렬 Σ 의 역행렬을 계산해야 합니다. 100,000 X 100,000 행렬의 역행렬을 계산할 때 엄청난 연산 비용이 필요합니다. 따라서, 다변량 가우시안 분포 모델은 n의 값이 너무 크면 사용하기 어렵습니다. 


   And finally for the original model, it turns out to work out ok even if you have a relatively small training set this is the small unlabeled examples that we use to model p of x of course, and this works fine, even if M is, you know, maybe 50, 100, works fine. Whereas for the multivariate Gaussian, it is sort of a mathematical property of the algorithm that you must have m greater than n, so that the number of examples is greater than the number of features you have. And there's a mathematical property of the way we estimate the parameters that if this is not true, so if m is less than or equal to n, then this matrix isn't even invertible, that is this matrix is singular, and so you can't even use the multivariate Gaussian model unless you make some changes to it. But a typical rule of thumb that I use is, I will use the multivariate Gaussian model only if m is much greater than n, so this is sort of the narrow mathematical requirement, but in practice, I would use the multivariate Gaussian model, only if m were quite a bit bigger than n. So if m were greater than or equal to 10 times n, let's say, might be a reasonable rule of thumb, and if it doesn't satisfy this, then the multivariate Gaussian model has a lot of parameters, right, so this covariance matrix sigma is an n by n matrix, so it has, you know, roughly n squared parameters, because it's a symmetric matrix, it's actually closer to n squared over 2 parameters, but this is a lot of parameters, so you need make sure you have a fairly large value for m, make sure you have enough data to fit all these parameters. And m greater than or equal to 10 n would be a reasonable rule of thumb to make sure that you can estimate this covariance matrix sigma reasonably well.


   마지막으로 원래 모델은 비교적 작은 학습 셋에서도 잘 작동합니다. p(x)를 모델링하기 위한 레이블이 없는 학습 예제 m이 적더라도 원래 모델은 잘 작동합니다. 아마 m = 50 또는 m = 100에서 잘 작동합니다. 다변량 가우시안 분포 모델은 수학적 특성상 m이 n 보다 커야 합니다. 즉, 예제의 수가 피처의 수보다 더 많아야 파라미터를 추정할 수 있습니다. 만일 m이 n 보다 작거나 같으면 행렬은 역행렬이 성립하지 않는 특이 행렬입니다. 이런 경우 다변량 가우시안 분포 모델을 사용할 수 없습니다. 일반적으로 m이 n 보다 훨씬 큰 경우에만 다변량 가우시안 분포 모델을 사용합니다.  이것은 일종의 수학적 요구 사항이지만 다변량 가우시안 분포 모델에만 사용합니다. m이 n 보다 상당히 크다는 의미는 m이 n 보다 10배 이상 크거가 같다는 것입니다. 이 경험 법칙이 충족되지 않으면 다변량 가우시안 분포 모델을 사용하지 않습니다. 다변량 가우시안 분포 모델은  많은 파라미터가 있습니다. 공분산 행렬 Σ 는 n X n 차원이므로 n^2의 파라미터가 있습니다. 대칭 행렬이기 때문에 실제로 2 개의 파라미터에 대해 각각 n^2의 파라미터가 있는 것입니다. m의 값이 상당히 큰 경우 모든 파라미터에 맞는 충분한 데이터가 있는 지를 확인합니다. 그리고, m이 n보다 10배 정도 크거가 같으면 공분산 행렬 Σ를 합리적으로 잘 추정할 수 있습니다. 

  

   So in practice the original model shown on the left that is used more often. And if you suspect that you need to capture correlations between features what people will often do is just manually design extra features like these to capture specific unusual combinations of values. But in problems where you have a very large training set or m is very large and n is   

not too large, then the multivariate Gaussian model is well worth considering and may work better as well, and can save you from having to spend your time to manually create extra features in case the anomalies turn out to be captured by unusual combinations of values of the features.


   실제로 왼쪽에 표시된 원래 모델을 더 자주 사용합니다. 이상 현상을 발견하기 위해 피처 간의 상관관계를 포착해야 할 경우 수동으로 추가적인 피처를 설계합니다. 그러나 학습 셋의 개수 m이 피처의 개수 n에 비해 매우 크다면,   다변량 가우시안 분포 모델을 고려할 가치가 있습니다. 알고리즘이 더 잘 작동할 수 있고, 추가 피처를 수동으로 생성하기 위해 시간을 소비할 필요도 없습니다. 

 

   Finally I just want to briefly mention one somewhat technical property, but if you're fitting multivariate Gaussian model, and if you find that the covariance matrix sigma is singular, or you find it's non-invertible, they're usually 2 cases for this. One is if it's failing to satisfy this m greater than n condition, and the second case is if you have redundant features. So by redundant features, I mean, if you have 2 features that are the same. Somehow you accidentally made two copies of the feature, so your x1 is just equal to x2. Or if you have redundant features like maybe your features X3 is equal to feature X4, plus feature X5. Okay, so if you have highly redundant features like these, you know, where if X3 is equal to X4 plus X5, well X3 doesn't contain any extra information, right? You just take these 2 other features, and add them together. And if you have this sort of redundant features, duplicated features, or this sort of features, than sigma may be non-invertible. 


   마지막으로 다소 기술적인 속성 하나를 간단하게 언급합니다. 다변량 가우시안 분포 모델을 적합시키고 공분산 행렬  Σ가 특이 행렬이거나 역행렬이 없다는 것을 발견한다면 일반적으로 두 가지 경우입니다. 하나는 n 보다 큰 m의 조건을 충족하지 못한 것입니다. 다른 하나는 중복된 피처가 있는 경우입니다. 중복된 피처란 동일한 피처가 2개 있는 경우입니다. 예를 들면, 우연히 피처의 두 복사본을 만들어서 x1과 x 2가 동일하거나 기능 x3는 x4와 x5를 더한 것과 같습니다. x3는 추가 정보가 없습니다. 이런 종류의 중복된 피처가 있을 때 공분산 행렬 Σ는 역행렬을 구할 수 없습니다. 


   And so there's a debugging set-- this should very rarely happen, so you probably won't run into this, it is very unlikely that you have to worry about this-- But in case you implement a multivariate Gaussian model you find that sigma is non-invertible. What I would do is first make sure that M is quite a bit bigger than N, and if it is then, the second thing I do, is just check for redundant features. And so if there are 2 features that are equal, just get rid of one of them, or if you have redundant if these , X3 equals X4 plus X5, just get rid of the redundant feature, and then it should work fine again. As an aside for those of you who are experts in linear algebra, by redundant features, what I mean is the formal term is features that are linearly dependent. But in practice what that really means is one of these problems tripping up the algorithm if you just make you features non-redundant., that should solve the problem of sigma being non-invertable. But once again the odds of your running into this at all are pretty low so chances are, you can just apply the multivariate Gaussian model, without having to worry about sigma being non-invertible, so long as m is greater than or equal to n. So that's it for anomaly detection, with the multivariate Gaussian distribution. And if you apply this method you would be able to have an anomaly detection algorithm that automatically captures positive and negative correlations between your different features and flags an anomaly if it sees is unusual combination of the values of the features.


    이것은 매우 드물게 생각합니다. 따라서, 부딪힐 가능성은 적으므로 걱정할 필요는 거의 없습니다.    다변량 가우시안 분포 모델을 구현할 때 Σ 가 비가역 행렬이라는 것이 밝혀지면, 가장 먼저 해야 할 것은 m이 n보다 상당히 큰 지를 확인하고, 중복된 피처가 있는 지를 확인하는 것입니다. 동일한 피처가 2개 있으면 그중에 하나를 제거하고, x3 + x4 = x5와 같은 경우에는 x5를 제거하면 정상적으로 동작합니다. 선형 대수의 전문가를 제외하고 중복된 피처라는 의미는 선형적으로 의존하는 피처라는 것입니다. 중복되지 않는 피처를 만들면 알고리즘은 정상적으로 작동합니다.  행렬 Σ 가 비가역 행렬인 원인을 찾아 문제를 해결합니다. 그러나 다시 한번 말하지만 가능성이 매우 낮으므로 m이 n 보다 크거나 같으면 시그마가 비가역 행렬이라는 걱정을 할 필요 없이 다변량 가우시안 분포 모델을 적용할 수 있습니다. 이것이 이상 탐지를 위한 다변량 가우시안 분포 모델입니다. 그리고, 다변량 가우시안 분포 모델은 서로 다른 피처들 사이의 양의 또는 음의 상관관계를 자동으로 포착하고 피처의 값이 비정상적인 조합이 발견되면 이상을 표시합니다. 



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




정리하며


   이상 탐지 알고리즘을 개발하는 방법은 다음과 같습니다. 파라미터를 추정하는 방법에 대해 이야기합니다. 이 있고,  각 예제는 R^(n) 차원의 벡터이자 다변량 가우시안 분포를 따릅니다. 평균 파라미터 μ와 분산 파라미터 Σ를 어떻게 추정할까요? 두 파라미터를 추정하는 표준 공식은 다음과 같습니다. 


   그리고, 이것은 실제로 주성분 분석 알고리즘 PCA (Principal Components Analysis)를 사용할 때 사용한 시그마와 같습니다. 두 공식을 활용하면 두 개의 파라미터를 추정할 수 있습니다.


1) x^(1), x^(2),..., x^(m)까지의 학습 예제를 구합니다.  

    레이블이 없는 학습 셋을 구합니다. 


1) 비정상적이거나 이상으로 구별할 수 있는 피처 xi를 결정합니다. 

    시스템에 사기 행위를 할 수도 있는 비정상적인 사용자나 비정상 항공기 엔진을 선별할 수 있는 피처를 정의합니다. 수학적으로 비정상적인 예는 피처 xi에 대해 비정상적으로 큰 값을 취하거나 비정상적으로 작은 값을 나타낼 것입니다.  


2) μ1,μ2,..., μn까지 파라미터와 σ1^2, σ2^2,..., σn^2까지의 파라미터 값을 추정합니다.  

     시스템에서 두 파라미터의 값을 추정하는 방법은 다음과 같습니다. 


                                m

      평균 μj = 1/m * Σ xj^(i)                                      

                            i = 1 

                                     m

       분산 Σ = 1/m * Σ (xj^(i) - μj)(xj^(i) - μj)^T   

                                   i = 1



3) 새로운 예제에 대해 모든 피처에 대한 확률 p(x)을 계산합니다. 

     새로운 예제가 주어졌을 때 즉 새로운 항공기 엔진이 주어졌을 때 이상이 있는 지를 판단합니다. 


     p(x)   

      = Π p(xj; μj, σj^2)

        =  Π 1/ (√(2πσj) exp(- (xj - μj)^2 / (2σj^2)))

  

 4) 새로운 예제가 이상인지 정상인지를 판단합니다.

       p(xtest)가 엡실론(ε) 보다 작으면 이상으로, 엡실론(ε) 보다 크면 정상으로 표시합니다. 이차원 그래프로 본다면 타원 밖에 있는 점들은 이상으로 표시하고, 타원 안에 있는 점들은 것들은 정상으로 표시합니다. 삼차원 그래프로 본다면 엡실론(ε) 보다 낮은 높이를 가진 점들은 이상으로 표시하고, 엡실론(ε) 보다 높은 값을 가진 점들은 정상으로 표시합니다.


확률 p(x)의 추정할 때

   원래 모델은 다음과 같이 정의했습니다. 


   

   다변량 가우시안 분포 모델은 다음과 같습니다. 



   여기서 확률 p(x)를 계산하는 두 가지 방법이 있습니다. 실제로  다변량 가우시안 분포를 사용하는 새 모델은 공분산 행렬 Σ의 비대각선 성분이 0인 경우입니다. 즉, 다변량 가우시안 분포의 특수한 사례가 원래 모델입니다. 


   일반적으로 원래 모델을 더 자주 사용하지만, 다변량 확률 분포 모델을 사용할 때가 있습니다. 


   첫 번째로 원래 모델은 새로운 피처를 수동으로 만들기 위해 시간을 할애할 때 활용하고, 변량 가우시안 분포 모델은 서로 다른 피처 간의 상관관계를 자동으로 포착합니다.  


   두 번째로 원래 모델은 연산 비용이 저렴합니다. 원래 모델은 n = 100,000에서도 잘 동작하지만 다변량 가우시안 분포 모델은 공분산 행렬 Σ가 R^(n X n) 차원입니다. 행렬 Σ의 역행렬을 계산할 때 엄청난 연산 비용이 필요합니다.


   마지막으로 원래 모델은 비교적 작은 학습 셋에서도 잘 작동합니다. 원래 모델은 m = 50 또는 m = 100에서도 문제가 없지만, 다변량 가우시안 분포 모델은 수학적 특성상 m이 n 보다 커야 합니다. 공분산 행렬 Σ의 역행렬을 구하기 어렵기 때문입니다. m이 n보다 커야 한다는 의미는 약 10배 정도 커야 한다는 뜻입니다.


   그리고, 다변량 가우시안 분포 모델을 적합시키고 공분산 행렬  Σ가 특이 행렬이거나 역행렬이 없다는 것을 발견한다면 일반적으로 두 가지 경우입니다. 하나는 n 보다 큰 m의 조건을 충족하지 못한 것입니다. 다른 하나는 중복된 피처가 있는 경우입니다.



문제 풀이


   학습 셋에서 이상 탐지 알고리즘을 적용을 고려중입니다. 다음 중 올바른 것은 무엇입니까?


정답은 1번 3번 4번입니다. 

매거진의 이전글 앤드류 응의 머신러닝(15-7):다변량 가우시안 분포
작품 선택
키워드 선택 0 / 3 0
댓글여부
afliean
브런치는 최신 브라우저에 최적화 되어있습니다. IE chrome safari