brunch

You can make anything
by writing

C.S.Lewis

by 라인하트 Dec 05. 2020

앤드류 응의 머신러닝(15-5):이상 탐지 대 지도학습

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



Anomaly Detection  

(이상 탐지)


Building an Anomaly Detection System

(이상 탐지 시스템 구축하기)   


Anomaly Detection vs. Supervised Learning

(이상 탐지 대 지도 학습)   


   In the last video we talked about the process of evaluating an anomaly detection algorithm. And there we started to use some label data with examples that we knew were either anomalous or not anomalous with Y equals one, or Y equals 0. And so, the question then arises of, and if we have the label data, that we have some examples and know the anomalies, and some of them will not be anomalies. Why don't we just use a supervisory learning algorithm? So why don't we just use logistic regression, or a neuron network to try to learn directly from our labeled data to predict whether Y equals one or Y equals 0. In this video, I'll try to share with you some of the thinking and some guidelines for when you should probably use an anomaly detection algorithm, and whether it might be more fruitful instead of using a supervisory learning algorithm. 


   지난 강의에서 이상 탐지 알고리즘을 평가하는 방법을 설명했습니다. 교차 검증 셋과 테스트 셋에서 y = 1 레이블을 가진 이상 예제와  y = 0 레이블을 가진 정상 예제를 사용했습니다. 이상 탐지 문제에서 정상과 이상을 표시할 수 있는 레이블이 있는 데이터가 있지만 지도 학습 알고리즘을 사용하지 않는 이유는 무엇일까요? 로지스틱 회귀와 인공 신경망이 레이블이 있는 데이터를 직접 학습하여 y = 1 또는 y = 0 인지를 예측합니다. 이번 강의는 문제의 종류에 따라 이상 탐지 알고리즘과 지도 학습 알고리즘 중에서 어느 것을 사용해야 하는지에 대한 가이드라인을 제시합니다.  



   This slide shows what are the settings under which you should maybe use anomaly detection versus when supervised learning might be more fruitful. If you have a problem with a very small number of positive examples, and remember the examples of y equals one are the anomaly examples. Then you might consider using an anomaly detection algorithm instead. So, having 0 to 20, it may be up to 50 positive examples, might be pretty typical. And usually we have such a small positive, set of positive examples, we're going to save the positive examples just for the cross validation set in the test set. And in contrast, in a typical normal anomaly detection setting, we will often have a relatively large number of negative examples of the normal examples of normal aircraft engines. And we can then use this very large number of negative examples With which to fit the model p(x). And so there's this idea that in many anomaly detection applications, you have very few positive examples and lots of negative examples. And when we're doing the process of estimating p(x), affecting all those Gaussian parameters, we need only negative examples to do that. So if you have a lot negative data, we can still fit p(x) pretty well.


   여기에서 이상 탐지와 지도 학습을 사용하는 경우를 설명합니다. 이상 탐지 알고리즘은 매우 적은 수의 예제가 y = 1 이상 예제입니다. 일반적으로 이상 예제의 수는 0개에서 20개까지이고, 최대 50개까지 정도입니다. 테스트 셋 또는 교차 검증 셋에서  y = 1 이상 예제를 사용합니다. 따라서 대부분의 예제는 y = 0 정상 예제입니다. 예를 들면, 항공기 엔진 사례를 떠올릴 수 있습니다. 대부분의 학습 예제는 정상이고, 항공기 엔진 예제에 적합한 모델 p(x)를 계산합니다. 이상 탐지 문제에서 정상 예제가 대부분이고, 이상 예제는 아주 적습니다. 가우시안 분포의 파라미터에 영향을 미치는 p(x)를 추정할 때 정상 예제만을 사용합니다. 정상 예제가 아주 많을 때  확률 p(x)를 추정합니다.   


   In contrast, for supervised learning, more typically we would have a reasonably large number of both positive and negative examples. And so this is one way to look at your problem and decide if you should use an anomaly detection algorithm or a supervised. 


   이와 달리 지도 학습은 다수의 정상 예제와 이상 예제가 있습니다. 이것이 이상 탐지 알고리즘과 지도 학습 알고리즘을 선택하는 방법 중 하나입니다.  



   Here's another way that people often think about anomaly detection. So for anomaly detection applications, often there are very different types of anomalies. So think about so many different ways for go wrong. There are so many things that could go wrong that could the aircraft engine. And so if that's the case, and if you have a pretty small set of positive examples, then it can be hard for an algorithm, difficult for an algorithm to learn from your small set of positive examples what the anomalies look like. And in particular, you know future anomalies may look nothing like the ones you've seen so far. So maybe in your set of positive examples, maybe you've seen 5 or 10 or 20 different ways that an aircraft engine could go wrong. But maybe tomorrow, you need to detect a totally new set, a totally new type of anomaly. A totally new way for an aircraft engine to be broken, that you've just never seen before. And if that's the case, it might be more promising to just model the negative examples with this sort of calcium model p of x instead of try to hard to model the positive examples. Because tomorrow's anomaly may be nothing like the ones you've seen so far.


   또 다른 이상 탐지 문제를 생각해 봅니다. 과거의 이상 사례와 완전히 다른 유형의 이상을 감지할 필요가 있는 경우입니다. 학습 알고리즘이 매우 적은 수의 이상 사례로 학습하기 어렵고, 미래에 발생할 새로운 유형의 이상 현상은 발견하기 어렵습니다. 예를 들면, 항공기 엔진 사례에서 과거와 다른 완전히 다른 형태의 이상 현상이 발생한다면, 일반 지도 학습 알고리즘은 발견하기 어렵습니다. 단지 5개, 10개, 또는 20개 정도의 이상 예제로는 완전히 새로운 유형의 이상을 탐지할 수 없습니다. 이상 탐지 알고리즘은 엔진이 망가질 수 있는 완전히 새로운 이상도 탐지해야 합니다. 이상 예제를 모델링하는 것보다 정상 예제에 대해 p(x)를 모델링하는 것이 훨씬 더 효과적입니다. 미래에 발견될 새로운 유형의 이상 현상은 지금까지와는 완전히 다른 유형이기 때문입니다.   

 

   In contrast, in some other problems, you have enough positive examples for an algorithm to get a sense of what the positive examples are like. In particular, if you think that future positive examples are likely to be similar to ones in the training set; then in that setting, it might be more reasonable to have a supervisory learning that looks at all of the positive examples, looks at all of the negative examples, and uses that to try to distinguish between positives and negatives.


   반면에 이상 현상이 무엇인지를 충분히 학습할 수 있는 수많은 이상 예제들이 있습니다. 특히 나중에 발견될 이상 예제는 대부분 학습 셋에 있습니다. 모든 정상 예제와 모든 이상 예제를 알고리즘이 학습한 후 정상과 이상을 구분하는 예측할 때 지도 학습 알고리즘이 효과적입니다.  


   Hopefully, this gives you a sense of if you have a specific problem, should you think about using an anomaly detection algorithm, or a supervised learning algorithm. And a key difference really is that in anomaly detection, often we have such a small number of positive examples that it is not possible for a learning algorithm to learn that much from the positive examples. And so what we do instead is take a large set of negative examples and have it just learn a lot, learn p(x) from just the negative examples of the normal aircraft engines and we've reserved the small number of positive examples for evaluating our algorithms to use in the either the cross validation set or the test set. 


   이번 강의는 학습 문제의 종류에 따라 이상 탐지 알고리즘과 지도 학습 알고리즘을 선택하는 요령을 설명했습니다. 이상 탐지 학습 알고리즘은 이상 예제에서 학습하는 것이 불가능할 정도로 이상 예제의 수가 너무 적은 것이  특징입니다. 따라서, 이상 탐지 알고리즘은 정상 예제에서 학습합니다. 항공기 엔진 사례에서 정상 예제에서 확률 p(x)를 모델링했습니다. 알고리즘을 평가하기 위해 이상 예제를 테스트 셋과 교차 검증 셋에 할당했습니다. 


   And just as a side comment about this many different types of anomalies. In some earlier videos we talked about the email spam examples. In those examples, there are actually many different types of spam email, right? There's spam email that's trying to sell you things. Spam email trying to steal your passwords, this is called phishing emails and many different types of spam emails. But for the spam problem we usually have enough examples of spam email to see most of these different types of spam email because we have a large set of examples of spam. And that's why we usually think of spam as a supervised learning setting even though there are many different types of.


   "많은 다양한 유형의 비정상적인 것들"에 대해 추가 설명합니다. 예전에 다루었던 스팸 이메일 문제는 서로 다른 유형의 비정상적인 것들의 대표적인 사례입니다. 물건을 파는 스팸 이메일, 비밀 번호를 훔치려는 피싱 이메일 등입니다. 스팸 이메일 문제를 지도 학습 알고리즘으로 처리하는 이유는 충분히 다양한 유형의 스팸 이메일을 수집할 수 있기 때문입니다.    




   If we look at some applications of anomaly detection versus supervised learning we'll find fraud detection. If you have many different types of ways for people to try to commit fraud and a relatively small number of fraudulent users on your website, then I use an anomaly detection algorithm. I should say, if you have, if you're a very major online retailer and if you actually have had a lot of people commit fraud on your website, so you actually have a lot of examples of y=1, then sometimes fraud detection could actually shift over to the supervised learning column. But, if you haven't seen that many examples of users doing strange things on your website, then more frequently fraud detection is actually treated as an anomaly detection algorithm rather than a supervised learning algorithm.


   사기 행위를 탐지하는 문제를 이상 탐지 알고리즘과 지도 학습 알고리즘을 적용하는 사례를 살펴봅시다. 온라인 쇼핑몰은 다양한 유형의 사기 행위가 발생할 수 있습니다. 하지만, 사기꾼의 수가 상대적으로 매우 적다면 이상 탐지 알고리즘이 효과적입니다. 반대로 사기꾼의 수가 상대적으로 많거나 y = 1의 예제가 충분하다면 지도 학습 알고리즘이 효과적입니다. 즉, 이상 행동을 하는 사용자의 예제가 아주 적을 때 이상 탐지 알고리즘이 효율적입니다.  


   Other examples, we've talked about manufacturing already. Hopefully, you see more and more examples are not that many anomalies but if again for some manufacturing processes, if you manufacture in very large volumes and you see a lot of bad examples, maybe manufacturing can shift to the supervised learning column as well. But if you haven't seen that many bad examples of so to do the anomaly detection monitoring machines in a data center similar source of apply. Whereas, email spam classification, weather prediction, and classifying cancers, if you have equal numbers of positive and negative examples. Your positive and your negative examples, then we would tend to treat all of these as supervisory learning problems. 


   제조업은 공장에서 불량품을 걸러냅니다. 상품을 많이 제조할수록 이상 예제의 수는 증가합니다. 그렇다면 제조업도 지도 학습 알고리즘을 활용할 수 있습니다. 데이터 센터에서 서버를 모니터링할 때 이상 예제를 많이 볼 수 없다면 이상 탐지 알고리즘을 활용합니다. 반면에 스팸 이메일 분류, 날씨 예측, 그리고 암 분류와 같이 동등한 수량의 정상 예제와 이상 예제가 있다면, 지도 학습 알고리즘을 활용합니다. 


   So hopefully, that gives you a sense of one of the properties of a learning problem that would cause you to treat it as an anomaly detection problem versus a supervisory problem. And for many other problems that are faced by various technology companies and so on, we actually are in the settings where we have very few or sometimes zero positive training examples. There's just so many different types of anomalies that we've never seen them before. And for those sorts of problems, very often the algorithm that is used is an anomaly detection algorithm.


   이번 강의에서 여러분이 이상 탐지 알고리즘과 지도 학습 알고리즘을 언제 사용할 지에 대한 감각을 익힐 수 있기를 기대합니다. 기업이 직면하는 수많은 문제들은 실제로 이상 예제가 거의 없거나 전혀 없습니다. 기업은 과거에 경험한 적이 없는 다양한 유형의 이상 현상을 마주합니다. 이상 탐지 알고리즘은 이런 문제를 해결합니다.  



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




정리하며


   기업이 직면하는 문제에 이상 탐지 알고리즘과 지도 학습 알고리즘 증 하나를 사용하는 감각을 익히기 위해 다양한 사례를 살펴봅니다. 


이상 탐지 알고리즘을 사용하는 경우 

 

   1) 정상 예제들이 아주 많고 이상 예제들이 아주 적을 때

         가우시안 분포 확률 p(x)를 추정할 때 정상적인 예제만을 활용

         교차 검증 셋과 테스트 셋에서 이상 예제를 활용하여 검증


   2) 미래에 발견될 이상이 지금까지 본 것과 완전히 다를 수 있을 때

         이상 예제의 수가 매우 적기 때문 


   3) 대표적인 사례

        온라인 웹사이트에 다양한 사기 행위가 있지만, 사기꾼의 수가 상대적으로 적을 때

        사기 탐지를 위한 이상 행동을 하는 사용자의 수가 극히 적을 때

        제조업 분야에서 불량률이 극히 적을 때

         데이터 센터에서 서버를 모니터링할 때 이상 예제가 극히 적을 때



지도 학습 알고리즘을 사용하는 경우


   1) 충분히 많은 수의 정상 예제와 이상 예제가 있을 때


   2) 미래에 발견될 이상이 지금까지 본 것과 같을 때

          충분히 많은 수의 이상 예제가 있기 때문

   

   3) 대표적인 사례

           스팸 이메일 문제 : 충분히 많은 수의 스팸 이메일을 확보할 수 있음

           온라인 웹사이트에 다양한 사기 행위가 있지만, 사기꾼의 수가 상대적으로 많을 때

           사기 탐지를 위한 이상 행동을 하는 사용자의 수가 많을 때 

           날씨 예측

           암 분류


 이상 탐지 알고리즘을 사용하다가 지도 학습 알고리즘으로 전환할 수 있는 경우


   1) 제조업 사례

       초기에는 불량률이 적어서 이상 탐지 알고리즘을 사용하고, 시간이 흐를수록 충분히 많은 불량 예제가 확보되었을 때 지도 학습 알고리즘을 적용할 수 있음



문제 풀이


   지도 학습 알고리즘 대신에 이상 탐지 알고리즘을 사용할 경우는 어떤 경우인가요?



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

매거진의 이전글 앤드류 응의 머신러닝(15-4):이상 탐지 시스템 평가

작품 선택

키워드 선택 0 / 3 0

댓글여부

afliean
브런치는 최신 브라우저에 최적화 되어있습니다. IE chrome safari